import functools





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





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





@functools.lru_cache(maxsize=None)

def dfs(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

    return ret





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

import functools





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





@functools.lru_cache(maxsize=None)

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





@functools.lru_cache(maxsize=None)

def dfs(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

    return ret





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

import functools

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


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


@functools.lru_cache(maxsize=None)
def dfs(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
    return ret


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

import functools

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


@functools.lru_cache(maxsize=None)
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


@functools.lru_cache(maxsize=None)
def dfs(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
    return ret


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

+@functools.lru_cache(maxsize=None)