# -*- coding: utf-8 -*-



import itertools

comb = list(map(''.join, itertools.product("ACGT", repeat=4)))



N = int(eval(input()))



dp = {c: [0, 0] for c in comb}

dp["TTTT"] = [1, 0]



for _ in range(N):

    dp_new = {c: [0, 0] for c in comb}

    for k in dp:

        for b in "ACGT":

            if k[2:4] + b in ("AGC", "ACG", "GAC") or k[1:4] + b in ("ACGC", "AGGC", "ATGC", "AGCC", "AGGC", "AGTC"):

                dp_new[k[1:4] + b][1] += dp[k][0] + dp[k][1]

            else:

                dp_new[k[1:4] + b][0] += dp[k][0]

                dp_new[k[1:4] + b][1] += dp[k][1]

    dp = dp_new



mod = int(1e9) + 7

print(((4 ** N - sum([dp[k][1] for k in dp])) % mod))

# -*- coding: utf-8 -*-



N = int(eval(input()))



dp = {b: 1 for b in "ACGT"}

for _ in range(N - 1):

    dp_new = {}

    for k in dp:

        for b in "ACGT":

            n = k[-3:] + b

            if n[-3:] in ("AGC", "ACG", "GAC") or n in ("ACGC", "AGGC", "ATGC", "AGCC", "AGGC", "AGTC"):

                continue

            else:

                if n in dp_new:

                    dp_new[n] += dp[k]

                else:

                    dp_new[n] = dp[k]

    dp = dp_new



print((sum(dp.values()) % (10 ** 9 + 7)))

# -*- coding: utf-8 -*-
import itertools

comb = list(map("".join, itertools.product("ACGT", repeat=4)))
N = int(eval(input()))
dp = {c: [0, 0] for c in comb}
dp["TTTT"] = [1, 0]
for _ in range(N):
    dp_new = {c: [0, 0] for c in comb}
    for k in dp:
        for b in "ACGT":
            if k[2:4] + b in ("AGC", "ACG", "GAC") or k[1:4] + b in (
                "ACGC",
                "AGGC",
                "ATGC",
                "AGCC",
                "AGGC",
                "AGTC",
            ):
                dp_new[k[1:4] + b][1] += dp[k][0] + dp[k][1]
            else:
                dp_new[k[1:4] + b][0] += dp[k][0]
                dp_new[k[1:4] + b][1] += dp[k][1]
    dp = dp_new
mod = int(1e9) + 7
print(((4**N - sum([dp[k][1] for k in dp])) % mod))

# -*- coding: utf-8 -*-
N = int(eval(input()))
dp = {b: 1 for b in "ACGT"}
for _ in range(N - 1):
    dp_new = {}
    for k in dp:
        for b in "ACGT":
            n = k[-3:] + b
            if n[-3:] in ("AGC", "ACG", "GAC") or n in (
                "ACGC",
                "AGGC",
                "ATGC",
                "AGCC",
                "AGGC",
                "AGTC",
            ):
                continue
            else:
                if n in dp_new:
                    dp_new[n] += dp[k]
                else:
                    dp_new[n] = dp[k]
    dp = dp_new
print((sum(dp.values()) % (10**9 + 7)))

-import itertools - -comb = list(map("".join, itertools.product("ACGT", repeat=4))) -dp = {c: [0, 0] for c in comb} -dp["TTTT"] = [1, 0] -for _ in range(N): -    dp_new = {c: [0, 0] for c in comb} +dp = {b: 1 for b in "ACGT"} +for _ in range(N - 1): +    dp_new = {} -            if k[2:4] + b in ("AGC", "ACG", "GAC") or k[1:4] + b in ( +            n = k[-3:] + b +            if n[-3:] in ("AGC", "ACG", "GAC") or n in ( -                dp_new[k[1:4] + b][1] += dp[k][0] + dp[k][1] +                continue -                dp_new[k[1:4] + b][0] += dp[k][0] -                dp_new[k[1:4] + b][1] += dp[k][1] +                if n in dp_new: +                    dp_new[n] += dp[k] +                else: +                    dp_new[n] = dp[k] -mod = int(1e9) + 7 -print(((4**N - sum([dp[k][1] for k in dp])) % mod)) +print((sum(dp.values()) % (10**9 + 7)))