from collections import defaultdict

N = int(eval(input()))

dp = [defaultdict(int) for _ in range(N+1)]

MOD = 10**9 + 7

dp[0]['TTT'] = 1





def ok(last4):

    for i in range(4):

        l = list(last4)

        if i >= 1:

            l[i-1], l[i] = l[i], l[i-1]

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

            return False

    return True





for n in range(N):

    for s, cnt in list(dp[n].items()):

        for c in 'AGCT':

            ns = s+c

            if ok(ns):

                dp[n+1][ns[-3:]] = (dp[n+1][ns[-3:]]+cnt) % MOD



print((sum(dp[N].values()) % MOD))

# ABC122D - We Like AGC

N, MOD = int(eval(input())), 10 ** 9 + 7

memo = [{} for i in range(N+1)]





def ok(last4):

    for i in range(4):

        t = list(last4)

        if i >= 1:

            t[i-1], t[i] = t[i], t[i-1]

        if ''.join(t).count('AGC') >= 1:

            return False

    return True





def dfs(cur, last3):

    if last3 in memo[cur]:

        return memo[cur][last3]

    if cur == N:

        return 1

    ret = 0

    for c in 'ACGT':

        if ok(last3 + c):

            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD

    memo[cur][last3] = ret

    return ret





print((dfs(0, 'TTT')))

from collections import defaultdict

N = int(eval(input()))
dp = [defaultdict(int) for _ in range(N + 1)]
MOD = 10**9 + 7
dp[0]["TTT"] = 1


def ok(last4):
    for i in range(4):
        l = list(last4)
        if i >= 1:
            l[i - 1], l[i] = l[i], l[i - 1]
        if "AGC" in "".join(l):
            return False
    return True


for n in range(N):
    for s, cnt in list(dp[n].items()):
        for c in "AGCT":
            ns = s + c
            if ok(ns):
                dp[n + 1][ns[-3:]] = (dp[n + 1][ns[-3:]] + cnt) % MOD
print((sum(dp[N].values()) % MOD))

# ABC122D - We Like AGC
N, MOD = int(eval(input())), 10**9 + 7
memo = [{} for i in range(N + 1)]


def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i - 1], t[i] = t[i], t[i - 1]
        if "".join(t).count("AGC") >= 1:
            return False
    return True


def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in "ACGT":
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret


print((dfs(0, "TTT")))

-from collections import defaultdict - -N = int(eval(input())) -dp = [defaultdict(int) for _ in range(N + 1)] -MOD = 10**9 + 7 -dp[0]["TTT"] = 1 +# ABC122D - We Like AGC +N, MOD = int(eval(input())), 10**9 + 7 +memo = [{} for i in range(N + 1)] -        l = list(last4) +        t = list(last4) -            l[i - 1], l[i] = l[i], l[i - 1] -        if "AGC" in "".join(l): +            t[i - 1], t[i] = t[i], t[i - 1] +        if "".join(t).count("AGC") >= 1: -for n in range(N): -    for s, cnt in list(dp[n].items()): -        for c in "AGCT": -            ns = s + c -            if ok(ns): -                dp[n + 1][ns[-3:]] = (dp[n + 1][ns[-3:]] + cnt) % MOD -print((sum(dp[N].values()) % MOD)) +def dfs(cur, last3): +    if last3 in memo[cur]: +        return memo[cur][last3] +    if cur == N: +        return 1 +    ret = 0 +    for c in "ACGT": +        if ok(last3 + c): +            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD +    memo[cur][last3] = ret +    return ret + + +print((dfs(0, "TTT")))