#include <bits/stdc++.h>
using namespace std;

const int64_t MOD = 1e9 + 7;
struct mint
{
    int64_t x;
    mint(int64_t x = 0) : x((x % MOD + MOD) % MOD) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += MOD - a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(int64_t n) const
    {
        if (n == 0)
            return 1;
        mint t = pow(n >> 1);
        t *= t;
        if (n & 1)
            t *= *this;
        return t;
    }
    mint inv() const { return pow(MOD - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};

const vector<string> TAIL = {"AAA", "AAC", "AAG", "AAT",
                             "ACA", "ACC", "ACG", "ACT",
                             "AGA", "AGC", "AGG", "AGT",
                             "ATA", "ATC", "ATG", "ATT",
                             "CAA", "CAC", "CAG", "CAT",
                             "CCA", "CCC", "CCG", "CCT",
                             "CGA", "CGC", "CGG", "CGT",
                             "CTA", "CTC", "CTG", "CTT",
                             "GAA", "GAC", "GAG", "GAT",
                             "GCA", "GCC", "GCG", "GCT",
                             "GGA", "GGC", "GGG", "GGT",
                             "GTA", "GTC", "GTG", "GTT",
                             "TAA", "TAC", "TAG", "TAT",
                             "TCA", "TCC", "TCG", "TCT",
                             "TGA", "TGC", "TGG", "TGT",
                             "TTA", "TTC", "TTG", "TTT"};

int main()
{
    int N;
    cin >> N;

    vector<vector<mint>> dp(N - 1, vector<mint>(64, 0));
    for (int i = 0; i < 64; i++)
    {
        string tail = TAIL.at(i);
        if (tail == "AGC" || tail == "GAC" || tail == "ACG")
        {
            continue;
        }
        dp.at(0).at(i) = 1;
    }
    for (int n = 1; n < N - 2; n++)
    {
        for (int i = 0; i < 64; i++)
        {
            string tail = TAIL.at(i);
            for (int j = 0; j < 64; j++)
            {
                string tail_prev = TAIL.at(j);
                if (tail.substr(0, 2) != tail_prev.substr(1, 2))
                {
                    continue;
                }
                if (tail == "AGC" || tail == "GAC" || tail == "ACG")
                {
                    continue;
                }
                if (tail_prev.at(0) == 'A' && tail.substr(1, 2) == "GC")
                {
                    continue;
                }
                if (tail_prev.substr(0, 2) == "AG" && tail.at(2) == 'C')
                {
                    continue;
                }
                dp.at(n).at(i) += dp.at(n - 1).at(j);
            }
        }
    }
    mint sum = 0;
    for (int i = 0; i < 64; i++)
    {
        sum += dp.at(N - 3).at(i);
    }
    cout << sum.x << endl;
}

Measured memory_bytes: 256