import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    string[] itos;
    void init(string S)
    {
        if (S.length == 3)
        {
            itos ~= S;
            return;
        }
        foreach (c; "ACGT")
            init(S ~ c);
        return;
    }

    init("");
    long M = itos.length;

    long[string] stoi;
    foreach (i; 0 .. M)
        stoi[itos[i]] = i;

    auto dp = new long[][](N + 1, M);

    foreach (i; 0 .. M)
    {
        dp[3][i] = (itos[i] != "AGC" && itos[i] != "ACG" && itos[i] != "GAC");
    }

    foreach (i; 3 .. N)
    {
        foreach (j; 0 .. M)
        {
            if (itos[j] == "AGC" || itos[j] == "ACG" || itos[j] == "GAC")
                continue;
            foreach (c; "ACGT")
            {
                string s4 = itos[j] ~ c;
                // writeln(s4);
                string s3 = s4[1 .. $];
                if (s3 == "AGC" || s3 == "ACG" || s3 == "GAC")
                    continue;
                if (s4[0] == 'A' && s4[2 .. $] == "GC")
                    continue;
                if (s4[0 .. 2] == "AG" && s4[$ - 1] == 'C')
                    continue;
                dp[i + 1][stoi[s3]] += dp[i][j];
                dp[i + 1][stoi[s3]] %= MOD;
            }
        }
        // writeln(dp[i]);
    }

    long ans;
    foreach (a; dp[N])
        ans = (ans + a) % MOD;

    writeln(ans);
}
