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

#define mod 1'000'000'007
typedef long long ll;

template <typename T>
void deb(initializer_list<T> l)
{
    for (auto &e : l)
        cout << e << ' ';
    cout << '\n';
}

ll n;
vector<vector<vector<vector<ll>>>> dp;

bool has(string s, char c)
{
    for (auto &e : s)
        if (e == c)
            return 1;
    return 0;
}
/*
ll f(ll i, ll c, ll p)
{
    if (i == n - 1)
        return 1;
    ll &ret = dp[i][c][p];
    if (ret != -1)
        return ret;
    if (p == 'Z' || c == 'T' || (c == 'C' && has("CGT", p)) || (c == 'G' && has("CGT", p)) || (c == 'A' && has("ACT", p)))
    {
        ret = f(i + 1, 'A', c) + f(i + 1, 'C', c);
        ret %= mod;
        ret += f(i + 1, 'G', c);
        ret %= mod;
        ret += f(i + 1, 'T', c);
        ret %= mod;
        return ret;
    }
    if (c == 'C' && p == 'A')
    {
        ret = f(i + 1, 'A', c) + f(i + 1, 'C', c);
        ret %= mod;
        ret += f(i + 1, 'T', c);
    }
    else if ((c == 'G' && p == 'A') || (c == 'A' && p == 'G'))
    {
        ret = f(i + 1, 'A', c) + f(i + 1, 'G', c);
        ret %= mod;
        ret += f(i + 1, 'T', c);
    }
    ret %= mod;
    return ret;
}/**/

string s;

bool has(string s)
{
    for (auto &e : { "AGC", "ACG", "GAC" })
        if (e == s)
            return 1;
    return 0;
}
//*
ll f(ll i, char p, char q, char c)
{
    s = p;
    s += q;
    s += c;
    if (i == n - 1)
    //    deb({s});
        return !has(s);
    ll &ret = dp[i][p - 'A'][q - 'A'][c - 'A'];
    if (ret != -1)
        return ret;//*
    if (has(s))
    {
        ret = 0;
        return ret;
    }
    ret = f(i + 1, q, c, 'A') + f(i + 1, q, c, 'G');
    ret %= mod;
    ret += f(i + 1, q, c, 'C');
    ret %= mod;
    ret += f(i + 1, q, c, 'T');
    ret %= mod;
    if (p == 'A' && (c == 'G' || q == 'G'))
    {
        ret -= f(i + 1, q, c, 'C');
        if (ret < 0)
            ret += mod;
    }
    return ret;/*
    if (p == 'Z' || c == 'T' || (c == 'C' && has("CGT", p)) || (c == 'G' && has("CGT", p)) || (c == 'A' && has("ACT", p)))
    {
        ret = f(i + 1, 'A', c) + f(i + 1, 'C', c);
        ret %= mod;
        ret += f(i + 1, 'G', c);
        ret %= mod;
        ret += f(i + 1, 'T', c);
        ret %= mod;
        return ret;
    }
    if (c == 'C' && p == 'A')
    {
        ret = f(i + 1, 'A', c) + f(i + 1, 'C', c);
        ret %= mod;
        ret += f(i + 1, 'T', c);
    }
    else if ((c == 'G' && p == 'A') || (c == 'A' && p == 'G'))
    {
        ret = f(i + 1, 'A', c) + f(i + 1, 'G', c);
        ret %= mod;
        ret += f(i + 1, 'T', c);
    }
    ret %= mod;
    return ret;/**/
}
/**/
void solve()
{
    cin >> n;
    dp.resize(n, vector<vector<vector<ll>>>(30, vector<vector<ll>>(30, vector<ll>(30, -1))));/*
    ll ans = f(0, 'A', 'Z');
    //deb({f(0, 'C', 'Z')});
    ans = (ans + f(0, 'C', 'Z')) % mod;
    ans = (ans + f(0, 'G', 'Z')) % mod;
    ans = (ans + f(0, 'T', 'Z')) % mod;
    cout << ans << '\n';/**/
    ll ans = f(0, 'Z', 'Z', 'A') + f(0, 'Z', 'Z', 'C');//*
    ans %= mod;
    ans += f(0, 'Z', 'Z', 'G');
    ans %= mod;
    ans += f(0, 'Z', 'Z', 'T');
    ans %= mod;
    cout << ans << '\n';/**/
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t { 1 };
//    cin >> t;
    while (t--)
        solve();

    return 0;
}


Measured memory_bytes: 25216