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



"""

参考：https://img.atcoder.jp/abc122/editorial.pdf

・数え上げDP

"""



import sys

from itertools import product

from collections import Counter



def input(): return sys.stdin.readline().strip()

def list2d(a, b, c): return [[c] * b for i in range(a)]

def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]

def ceil(x, y=1): return int(-(-x // y))

def INT(): return int(eval(input()))

def MAP(): return list(map(int, input().split()))

def LIST(): return list(map(int, input().split()))

def Yes(): print('Yes')

def No(): print('No')

def YES(): print('YES')

def NO(): print('NO')

sys.setrecursionlimit(10 ** 9)

INF = float('inf')

MOD = 10 ** 9 + 7



N=INT()



# dp[i][j] := 全部でi文字の時、最後の3文字がjとなる文字列の数

dp=[Counter() for i in range(N+1)]

keys = [''.join(key) for key in product('ACGT', repeat=3)]

# 3文字での初期値

for key in keys:

    if key not in ['AGC', 'GAC', 'ACG']:

        dp[3][key]=1



keys = [''.join(key) for key in product('ACGT', repeat=4)]

for i in range(4, N+1):

    for key in keys:

        for j in range(4):

            tmp=list(key)

            if j>=1:

                # 隣同士をスワップさせる

                tmp[j],tmp[j-1]=tmp[j-1],tmp[j]

            if ''.join(tmp).count('AGC'):

                break

        else:

            # 4パターンいずれもAGCを含まないものだけ遷移させる

            cur,nxt=key[:3],key[1:]

            dp[i][nxt]=(dp[i][nxt]+dp[i-1][cur])%MOD

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

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



import sys



def input(): return sys.stdin.readline().strip()

def list2d(a, b, c): return [[c] * b for i in range(a)]

def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1): return int(-(-x // y))

def INT(): return int(eval(input()))

def MAP(): return list(map(int, input().split()))

def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes(): print('Yes')

def No(): print('No')

def YES(): print('YES')

def NO(): print('NO')

sys.setrecursionlimit(10 ** 9)

INF = 10 ** 18

MOD = 10 ** 9 + 7



N = INT()



# dp[i][j][k][l] := i文字目まで見て、3文字前がj、2文字前がk、1文字前がlである通り数

dp = list4d(N+1, 5, 5, 5, 0)

dp[0][0][0][0] = 1



# A: 1, C: 2, G: 3, T: 4

for i in range(N):

    for j in range(5):

        for k in range(5):

            for l in range(5):

                # A,C,G,Tへの遷移

                for m in range(1, 5):

                    # AGC

                    if k == 1 and l == 3 and m == 2:

                        continue

                    # ACG

                    elif k == 1 and l == 2 and m == 3:

                        continue

                    # GAC

                    elif k == 3 and l == 1 and m == 2:

                        continue

                    # A?GC

                    elif j == 1 and l == 3 and m == 2:

                        continue

                    # AG?C

                    elif j == 1 and k == 3 and m == 2:

                        continue

                    dp[i+1][k][l][m] += dp[i][j][k][l]

                    dp[i+1][k][l][m] %= MOD

ans = 0

for j in range(5):

    for k in range(5):

        for l in range(5):

            ans += dp[N][j][k][l]

            ans %= MOD

print(ans)

# -*- coding: utf-8 -*-
"""
参考：https://img.atcoder.jp/abc122/editorial.pdf
・数え上げDP
"""
import sys
from itertools import product
from collections import Counter


def input():
    return sys.stdin.readline().strip()


def list2d(a, b, c):
    return [[c] * b for i in range(a)]


def list3d(a, b, c, d):
    return [[[d] * c for j in range(b)] for i in range(a)]


def ceil(x, y=1):
    return int(-(-x // y))


def INT():
    return int(eval(input()))


def MAP():
    return list(map(int, input().split()))


def LIST():
    return list(map(int, input().split()))


def Yes():
    print("Yes")


def No():
    print("No")


def YES():
    print("YES")


def NO():
    print("NO")


sys.setrecursionlimit(10**9)
INF = float("inf")
MOD = 10**9 + 7
N = INT()
# dp[i][j] := 全部でi文字の時、最後の3文字がjとなる文字列の数
dp = [Counter() for i in range(N + 1)]
keys = ["".join(key) for key in product("ACGT", repeat=3)]
# 3文字での初期値
for key in keys:
    if key not in ["AGC", "GAC", "ACG"]:
        dp[3][key] = 1
keys = ["".join(key) for key in product("ACGT", repeat=4)]
for i in range(4, N + 1):
    for key in keys:
        for j in range(4):
            tmp = list(key)
            if j >= 1:
                # 隣同士をスワップさせる
                tmp[j], tmp[j - 1] = tmp[j - 1], tmp[j]
            if "".join(tmp).count("AGC"):
                break
        else:
            # 4パターンいずれもAGCを含まないものだけ遷移させる
            cur, nxt = key[:3], key[1:]
            dp[i][nxt] = (dp[i][nxt] + dp[i - 1][cur]) % MOD
print(((sum(dp[N].values())) % MOD))

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


def input():
    return sys.stdin.readline().strip()


def list2d(a, b, c):
    return [[c] * b for i in range(a)]


def list3d(a, b, c, d):
    return [[[d] * c for j in range(b)] for i in range(a)]


def list4d(a, b, c, d, e):
    return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]


def ceil(x, y=1):
    return int(-(-x // y))


def INT():
    return int(eval(input()))


def MAP():
    return list(map(int, input().split()))


def LIST(N=None):
    return list(MAP()) if N is None else [INT() for i in range(N)]


def Yes():
    print("Yes")


def No():
    print("No")


def YES():
    print("YES")


def NO():
    print("NO")


sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7
N = INT()
# dp[i][j][k][l] := i文字目まで見て、3文字前がj、2文字前がk、1文字前がlである通り数
dp = list4d(N + 1, 5, 5, 5, 0)
dp[0][0][0][0] = 1
# A: 1, C: 2, G: 3, T: 4
for i in range(N):
    for j in range(5):
        for k in range(5):
            for l in range(5):
                # A,C,G,Tへの遷移
                for m in range(1, 5):
                    # AGC
                    if k == 1 and l == 3 and m == 2:
                        continue
                    # ACG
                    elif k == 1 and l == 2 and m == 3:
                        continue
                    # GAC
                    elif k == 3 and l == 1 and m == 2:
                        continue
                    # A?GC
                    elif j == 1 and l == 3 and m == 2:
                        continue
                    # AG?C
                    elif j == 1 and k == 3 and m == 2:
                        continue
                    dp[i + 1][k][l][m] += dp[i][j][k][l]
                    dp[i + 1][k][l][m] %= MOD
ans = 0
for j in range(5):
    for k in range(5):
        for l in range(5):
            ans += dp[N][j][k][l]
            ans %= MOD
print(ans)

-""" -参考：https://img.atcoder.jp/abc122/editorial.pdf -・数え上げDP -""" -from itertools import product -from collections import Counter +def list4d(a, b, c, d, e): +    return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] + + -def LIST(): -    return list(map(int, input().split())) +def LIST(N=None): +    return list(MAP()) if N is None else [INT() for i in range(N)] -INF = float("inf") +INF = 10**18 -# dp[i][j] := 全部でi文字の時、最後の3文字がjとなる文字列の数 -dp = [Counter() for i in range(N + 1)] -keys = ["".join(key) for key in product("ACGT", repeat=3)] -# 3文字での初期値 -for key in keys: -    if key not in ["AGC", "GAC", "ACG"]: -        dp[3][key] = 1 -keys = ["".join(key) for key in product("ACGT", repeat=4)] -for i in range(4, N + 1): -    for key in keys: -        for j in range(4): -            tmp = list(key) -            if j >= 1: -                # 隣同士をスワップさせる -                tmp[j], tmp[j - 1] = tmp[j - 1], tmp[j] -            if "".join(tmp).count("AGC"): -                break -        else: -            # 4パターンいずれもAGCを含まないものだけ遷移させる -            cur, nxt = key[:3], key[1:] -            dp[i][nxt] = (dp[i][nxt] + dp[i - 1][cur]) % MOD -print(((sum(dp[N].values())) % MOD)) +# dp[i][j][k][l] := i文字目まで見て、3文字前がj、2文字前がk、1文字前がlである通り数 +dp = list4d(N + 1, 5, 5, 5, 0) +dp[0][0][0][0] = 1 +# A: 1, C: 2, G: 3, T: 4 +for i in range(N): +    for j in range(5): +        for k in range(5): +            for l in range(5): +                # A,C,G,Tへの遷移 +                for m in range(1, 5): +                    # AGC +                    if k == 1 and l == 3 and m == 2: +                        continue +                    # ACG +                    elif k == 1 and l == 2 and m == 3: +                        continue +                    # GAC +                    elif k == 3 and l == 1 and m == 2: +                        continue +                    # A?GC +                    elif j == 1 and l == 3 and m == 2: +                        continue +                    # AG?C +                    elif j == 1 and k == 3 and m == 2: +                        continue +                    dp[i + 1][k][l][m] += dp[i][j][k][l] +                    dp[i + 1][k][l][m] %= MOD +ans = 0 +for j in range(5): +    for k in range(5): +        for l in range(5): +            ans += dp[N][j][k][l] +            ans %= MOD +print(ans)