

fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val ans = getAns("", n)
    println(ans)
}

val dic = mutableMapOf<String,MutableMap<Int, Long>>()

fun getAns(log:String,remain:Int):Long {
    val key = if(log.length <= 4) log else log.takeLast(4)
    if(!dic.containsKey(key)) {
        dic[key] = mutableMapOf()
    }
    dic[key]!![remain]?.let { return it }
    if(remain == 0) {
        return if(isValid(key)) 1 else 0
    }
    var ans = 0L
    for(c in "ACGT") {
        if(!isValid((key+c).takeLast(4))) {
            continue
        }
        ans += getAns(key+c, remain-1)
        ans = ans % (1000000000 + 7)
    }
    dic[key]!![remain]= ans
    return ans
}

val validDic = mutableMapOf<String, Boolean>()
fun isValid(target:String):Boolean {
    if(validDic.containsKey(target)) {
        return validDic[target]!!
    }
    if(target.length < 3) {
        validDic[target] = true
        return true
    }
    if(target.contains("AGC")) {
        validDic[target] = false
        return false
    }
    for(i in (1 until target.length)) {
        val tmp = target.toMutableList()
        val c = tmp[i]
        tmp[i] = tmp[i-1]
        tmp[i-1] = c
        val unValid = tmp.joinToString("")
        if(unValid.contains("AGC")) {
            validDic[target] = false
            return false
        }
    }
    validDic[target] = true
    return true
}


