import re



def makelist(n, m):

    return [[0 for i in range(m)] for j in range(n)]



N = int(eval(input()))



acgt = ["A", "C", "G", "T"]

changed = [".*GAC.*", ".*ACG.*", ".*A.GC.*", ".*AG.C.*"]

bad = ".*AGC"





# initialize

dp = {}

for a in acgt:

    for b in acgt:

        for c in acgt:

            now = a+b+c

            

            if re.match(bad, now):

                dp[now] = 0

            elif any([re.match(ch, now) for ch in changed]):

                dp[now] = 0

            else:

                dp[now] = 1



N -= 3



MOD = int(1e9) + 7

# main

while N > 0:

    dpNow = {}

    for a in acgt:

        for b in acgt:

            for c in acgt:

                abc = (a + b + c)[:min(N, 3)]

                dpNow[abc] = 0

                for key, value in list(dp.items()):

                    now = key + abc



                    if re.match(bad, now):

                        ()

                    elif any([re.match(ch, now) for ch in changed]):

                        ()

                    else:

                        dpNow[abc] += value

                        dpNow[abc] %= MOD

                        

    dp = dpNow

    N -= 3



ans = 0

for v in list(dp.values()):

    ans += v

    ans %= MOD



print(ans)

import re



def makelist(n, m):

    return [[0 for i in range(m)] for j in range(n)]



N = int(eval(input()))



acgt = ["A", "C", "G", "T"]

changed = [".*AGC", ".*GAC", ".*ACG", ".*A.GC", ".*AG.C"]





# initialize

dp = {}

for a in acgt:

    for b in acgt:

        for c in acgt:

            now = a+b+c

            

            if any([re.match(ch, now) for ch in changed]):

                dp[now] = 0

            else:

                dp[now] = 1



N -= 3



MOD = int(1e9) + 7

# main

while N > 0:

    dpNow = {}

    for a in acgt:

        for b in acgt:

            for c in acgt:

                abc = (a + b + c)[:min(N, 3)]

                dpNow[abc] = 0

                for key, value in list(dp.items()):

                    now = key + abc



                    if not any([re.match(ch, now) for ch in changed]):

                        dpNow[abc] += value

                        dpNow[abc] %= MOD

                        

    dp = dpNow

    N -= 3



ans = 0

for v in list(dp.values()):

    ans += v

    ans %= MOD



print(ans)

import re


def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]


N = int(eval(input()))
acgt = ["A", "C", "G", "T"]
changed = [".*GAC.*", ".*ACG.*", ".*A.GC.*", ".*AG.C.*"]
bad = ".*AGC"
# initialize
dp = {}
for a in acgt:
    for b in acgt:
        for c in acgt:
            now = a + b + c
            if re.match(bad, now):
                dp[now] = 0
            elif any([re.match(ch, now) for ch in changed]):
                dp[now] = 0
            else:
                dp[now] = 1
N -= 3
MOD = int(1e9) + 7
# main
while N > 0:
    dpNow = {}
    for a in acgt:
        for b in acgt:
            for c in acgt:
                abc = (a + b + c)[: min(N, 3)]
                dpNow[abc] = 0
                for key, value in list(dp.items()):
                    now = key + abc
                    if re.match(bad, now):
                        ()
                    elif any([re.match(ch, now) for ch in changed]):
                        ()
                    else:
                        dpNow[abc] += value
                        dpNow[abc] %= MOD
    dp = dpNow
    N -= 3
ans = 0
for v in list(dp.values()):
    ans += v
    ans %= MOD
print(ans)

import re


def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]


N = int(eval(input()))
acgt = ["A", "C", "G", "T"]
changed = [".*AGC", ".*GAC", ".*ACG", ".*A.GC", ".*AG.C"]
# initialize
dp = {}
for a in acgt:
    for b in acgt:
        for c in acgt:
            now = a + b + c
            if any([re.match(ch, now) for ch in changed]):
                dp[now] = 0
            else:
                dp[now] = 1
N -= 3
MOD = int(1e9) + 7
# main
while N > 0:
    dpNow = {}
    for a in acgt:
        for b in acgt:
            for c in acgt:
                abc = (a + b + c)[: min(N, 3)]
                dpNow[abc] = 0
                for key, value in list(dp.items()):
                    now = key + abc
                    if not any([re.match(ch, now) for ch in changed]):
                        dpNow[abc] += value
                        dpNow[abc] %= MOD
    dp = dpNow
    N -= 3
ans = 0
for v in list(dp.values()):
    ans += v
    ans %= MOD
print(ans)

-changed = [".*GAC.*", ".*ACG.*", ".*A.GC.*", ".*AG.C.*"] -bad = ".*AGC" +changed = [".*AGC", ".*GAC", ".*ACG", ".*A.GC", ".*AG.C"] -            if re.match(bad, now): -                dp[now] = 0 -            elif any([re.match(ch, now) for ch in changed]): +            if any([re.match(ch, now) for ch in changed]): -                    if re.match(bad, now): -                        () -                    elif any([re.match(ch, now) for ch in changed]): -                        () -                    else: +                    if not any([re.match(ch, now) for ch in changed]):