import sys



sys.setrecursionlimit(10 ** 6)

mod = 10 ** 9 + 7





def is_ok(last4):

    for j in range(4):

        t = list(last4)

        if j != 3:

            t[j], t[j + 1] = t[j + 1], t[j]

        if 'AGC' in ''.join(t):

            return False

    return True





def rec(length, last3):

    if last3 in m[length]:

        return m[length][last3]



    if length == n:

        return 1



    res = 0

    for c in 'ACGT':

        if is_ok(last3 + c):

            res += rec(length + 1, last3[1:] + c)

            res %= mod



    m[length][last3] = res

    return res





n = int(eval(input()))

m = [dict() for _ in range(n + 1)]

print((rec(0, 'zzz')))

def solve():

    from functools import lru_cache



    mod = 10 ** 9 + 7



    def is_ok(last4: str) -> bool:

        if 'AGC' in last4:

            return False

        for j in range(3):

            t = list(last4)

            t[j], t[j + 1] = t[j + 1], t[j]

            if 'AGC' in ''.join(t):

                return False

        return True



    @lru_cache(maxsize=None)

    def dfs(curr: int = 0, last3: str = 'XXX'):

        ret = 0

        if curr == n:

            return 1

        for c in 'ACGT':

            last4 = last3 + c

            if is_ok(last4):

                ret += dfs(curr + 1, last4[1:])

        return ret % mod



    n = int(eval(input()))

    print((dfs()))





solve()

import sys

sys.setrecursionlimit(10**6)
mod = 10**9 + 7


def is_ok(last4):
    for j in range(4):
        t = list(last4)
        if j != 3:
            t[j], t[j + 1] = t[j + 1], t[j]
        if "AGC" in "".join(t):
            return False
    return True


def rec(length, last3):
    if last3 in m[length]:
        return m[length][last3]
    if length == n:
        return 1
    res = 0
    for c in "ACGT":
        if is_ok(last3 + c):
            res += rec(length + 1, last3[1:] + c)
            res %= mod
    m[length][last3] = res
    return res


n = int(eval(input()))
m = [dict() for _ in range(n + 1)]
print((rec(0, "zzz")))

def solve():
    from functools import lru_cache

    mod = 10**9 + 7

    def is_ok(last4: str) -> bool:
        if "AGC" in last4:
            return False
        for j in range(3):
            t = list(last4)
            t[j], t[j + 1] = t[j + 1], t[j]
            if "AGC" in "".join(t):
                return False
        return True

    @lru_cache(maxsize=None)
    def dfs(curr: int = 0, last3: str = "XXX"):
        ret = 0
        if curr == n:
            return 1
        for c in "ACGT":
            last4 = last3 + c
            if is_ok(last4):
                ret += dfs(curr + 1, last4[1:])
        return ret % mod

    n = int(eval(input()))
    print((dfs()))


solve()

-import sys +def solve(): +    from functools import lru_cache -sys.setrecursionlimit(10**6) -mod = 10**9 + 7 +    mod = 10**9 + 7 + +    def is_ok(last4: str) -> bool: +        if "AGC" in last4: +            return False +        for j in range(3): +            t = list(last4) +            t[j], t[j + 1] = t[j + 1], t[j] +            if "AGC" in "".join(t): +                return False +        return True + +    @lru_cache(maxsize=None) +    def dfs(curr: int = 0, last3: str = "XXX"): +        ret = 0 +        if curr == n: +            return 1 +        for c in "ACGT": +            last4 = last3 + c +            if is_ok(last4): +                ret += dfs(curr + 1, last4[1:]) +        return ret % mod + +    n = int(eval(input())) +    print((dfs())) -def is_ok(last4): -    for j in range(4): -        t = list(last4) -        if j != 3: -            t[j], t[j + 1] = t[j + 1], t[j] -        if "AGC" in "".join(t): -            return False -    return True - - -def rec(length, last3): -    if last3 in m[length]: -        return m[length][last3] -    if length == n: -        return 1 -    res = 0 -    for c in "ACGT": -        if is_ok(last3 + c): -            res += rec(length + 1, last3[1:] + c) -            res %= mod -    m[length][last3] = res -    return res - - -n = int(eval(input())) -m = [dict() for _ in range(n + 1)] -print((rec(0, "zzz"))) +solve()