def main():

    n = int(eval(input()))

    MOD = 10 ** 9 + 7

    note = [{} for _ in range(n+1)]



    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



    def dfs(cur, last3):

        if last3 in note[cur]:

            return note[cur][last3]

        if cur == n:

            return 1

        ret = 0

        for c in 'ACGT':

            if ok(last3 + c):

                ret += dfs(cur + 1, last3[1:] + c)

                ret %= MOD

        note[cur][last3] = ret

        return ret



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





main()

# from https://atcoder.jp/contests/abc122/submissions/4932940





def main():

    n = int(eval(input()))

    MOD = 10 ** 9 + 7



    dpa = [0, 0, 1]

    dpc = [0, 0, 1]

    dpg = [0, 0, 1]

    dpt = [0, 0, 1]

    for i in range(2, n + 2):

        total = dpa[i] + dpc[i] + dpg[i] + dpt[i]

        if i == n + 1:

            break

        dpa.append(total)

        dpc.append(total - dpa[i-1] - dpg[i-1] - 3 * dpa[i-2])

        dpg.append(total - dpa[i-1] + dpg[i-2])

        dpt.append(total)

    print((total % MOD))





main()

def main():
    n = int(eval(input()))
    MOD = 10**9 + 7
    note = [{} for _ in range(n + 1)]

    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

    def dfs(cur, last3):
        if last3 in note[cur]:
            return note[cur][last3]
        if cur == n:
            return 1
        ret = 0
        for c in "ACGT":
            if ok(last3 + c):
                ret += dfs(cur + 1, last3[1:] + c)
                ret %= MOD
        note[cur][last3] = ret
        return ret

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


main()

# from https://atcoder.jp/contests/abc122/submissions/4932940
def main():
    n = int(eval(input()))
    MOD = 10**9 + 7
    dpa = [0, 0, 1]
    dpc = [0, 0, 1]
    dpg = [0, 0, 1]
    dpt = [0, 0, 1]
    for i in range(2, n + 2):
        total = dpa[i] + dpc[i] + dpg[i] + dpt[i]
        if i == n + 1:
            break
        dpa.append(total)
        dpc.append(total - dpa[i - 1] - dpg[i - 1] - 3 * dpa[i - 2])
        dpg.append(total - dpa[i - 1] + dpg[i - 2])
        dpt.append(total)
    print((total % MOD))


main()

+# from https://atcoder.jp/contests/abc122/submissions/4932940 -    note = [{} for _ in range(n + 1)] - -    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 - -    def dfs(cur, last3): -        if last3 in note[cur]: -            return note[cur][last3] -        if cur == n: -            return 1 -        ret = 0 -        for c in "ACGT": -            if ok(last3 + c): -                ret += dfs(cur + 1, last3[1:] + c) -                ret %= MOD -        note[cur][last3] = ret -        return ret - -    print((dfs(0, "TTT"))) +    dpa = [0, 0, 1] +    dpc = [0, 0, 1] +    dpg = [0, 0, 1] +    dpt = [0, 0, 1] +    for i in range(2, n + 2): +        total = dpa[i] + dpc[i] + dpg[i] + dpt[i] +        if i == n + 1: +            break +        dpa.append(total) +        dpc.append(total - dpa[i - 1] - dpg[i - 1] - 3 * dpa[i - 2]) +        dpg.append(total - dpa[i - 1] + dpg[i - 2]) +        dpt.append(total) +    print((total % MOD))