from functools import lru_cache





def check(s):

    bads = ["AGC", "ACG", "GAC"] + [b.format(_s) for b in ["AG{}C", "A{}GC"] for _s in "ACGT"]

    return not any([x in s for x in bads])





def solve(string):

    n = int(string)



    @lru_cache(n * 4**3)

    def dfs(pos, last3):

        if pos == n:

            return 1

        ans = 0

        for _s in "ACGT":

            ans += dfs(pos + 1, last3[1:] + _s) if check(last3 + _s) else 0

        return ans % (10**9 + 7)



    return str(dfs(0, "TTT"))





if __name__ == '__main__':

    print((solve(eval(input()))))

def solve(string):

    n = int(string)

    dp = [[0] * 4 for _ in range(n)]

    dp[0] = [1] * 4

    for i in range(1, n):

        base = sum(dp[i - 1])

        for j in range(4):

            dp[i][j] = base

        # "AGC", "ACG", "GAC"

        if i >= 2:

            dp[i][1] -= dp[i - 2][0] + dp[i - 2][2]

            dp[i][2] -= dp[i - 2][0]

        # "AG{}C", "A{}GC"

        if i >= 3:

            dp[i][1] -= dp[i - 3][0] * 3

            dp[i][2] += dp[i - 3][2]



    return str(sum(dp[n - 1]) % (10**9 + 7))





if __name__ == '__main__':

    print((solve(eval(input()))))

from functools import lru_cache


def check(s):
    bads = ["AGC", "ACG", "GAC"] + [
        b.format(_s) for b in ["AG{}C", "A{}GC"] for _s in "ACGT"
    ]
    return not any([x in s for x in bads])


def solve(string):
    n = int(string)

    @lru_cache(n * 4**3)
    def dfs(pos, last3):
        if pos == n:
            return 1
        ans = 0
        for _s in "ACGT":
            ans += dfs(pos + 1, last3[1:] + _s) if check(last3 + _s) else 0
        return ans % (10**9 + 7)

    return str(dfs(0, "TTT"))


if __name__ == "__main__":
    print((solve(eval(input()))))

def solve(string):
    n = int(string)
    dp = [[0] * 4 for _ in range(n)]
    dp[0] = [1] * 4
    for i in range(1, n):
        base = sum(dp[i - 1])
        for j in range(4):
            dp[i][j] = base
        # "AGC", "ACG", "GAC"
        if i >= 2:
            dp[i][1] -= dp[i - 2][0] + dp[i - 2][2]
            dp[i][2] -= dp[i - 2][0]
        # "AG{}C", "A{}GC"
        if i >= 3:
            dp[i][1] -= dp[i - 3][0] * 3
            dp[i][2] += dp[i - 3][2]
    return str(sum(dp[n - 1]) % (10**9 + 7))


if __name__ == "__main__":
    print((solve(eval(input()))))

-from functools import lru_cache - - -def check(s): -    bads = ["AGC", "ACG", "GAC"] + [ -        b.format(_s) for b in ["AG{}C", "A{}GC"] for _s in "ACGT" -    ] -    return not any([x in s for x in bads]) - - - -    @lru_cache(n * 4**3) -    def dfs(pos, last3): -        if pos == n: -            return 1 -        ans = 0 -        for _s in "ACGT": -            ans += dfs(pos + 1, last3[1:] + _s) if check(last3 + _s) else 0 -        return ans % (10**9 + 7) - -    return str(dfs(0, "TTT")) +    dp = [[0] * 4 for _ in range(n)] +    dp[0] = [1] * 4 +    for i in range(1, n): +        base = sum(dp[i - 1]) +        for j in range(4): +            dp[i][j] = base +        # "AGC", "ACG", "GAC" +        if i >= 2: +            dp[i][1] -= dp[i - 2][0] + dp[i - 2][2] +            dp[i][2] -= dp[i - 2][0] +        # "AG{}C", "A{}GC" +        if i >= 3: +            dp[i][1] -= dp[i - 3][0] * 3 +            dp[i][2] += dp[i - 3][2] +    return str(sum(dp[n - 1]) % (10**9 + 7))