"use strict";
function Main(input) {
    let N = input.split("\n")[0].split(/\s/).map((v) => v - 0)[0];
    let dp = new Array(N + 1).fill(0).map(() => new Array(4).fill(0).map(() => new Array(4).fill(0).map(() => new Array(4).fill(0))));
    const MOD = 1e+9 + 7;
    // A C G T -> 0 1 2 3
    dp[0][3][3][3] = 1;
    for (let len = 0; len < N; len++)
        for (let c1 = 0; c1 < 4; c1++)
            for (let c2 = 0; c2 < 4; c2++)
                for (let c3 = 0; c3 < 4; c3++) {
                    if (dp[len][c1][c2][c3] == 0) continue;
                    for (let a = 0; a < 4; a++) {
                        if (a == 2 && c1 == 1 && c2 == 0) continue; // 0 1 2
                        if (a == 2 && c1 == 0 && c2 == 1) continue; // 1 0 2
                        if (a == 1 && c1 == 2 && c2 == 0) continue; // 0 2 1
                        if (a == 2 && c1 == 1 && c3 == 0) continue; // 0 ? 1 2
                        if (a == 2 && c2 == 1 && c3 == 0) continue; // 0 1 ? 2
                        // S = ...... c3 c2 c1
                        // nextS = ...... c2 c1 a
                        dp[len + 1][a][c1][c2] += dp[len][c1][c2][c3];
                        dp[len + 1][a][c1][c2] %= MOD;
                    }
                }
    let ans = 0;
    for (let c1 = 0; c1 < 4; c1++)
        for (let c2 = 0; c2 < 4; c2++)
            for (let c3 = 0; c3 < 4; c3++) {
                ans += dp[N][c1][c2][c3];
                ans %= MOD;
            }
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
