#include <bits/stdc++.h>
using namespace std;
//#define DEBUG_MODE
#define endl '\n'
#ifdef DEBUG_MODE
#define DEBUG(X) debug_func(X, #X)
#define DEBUG_ENDL endl << flush
#define DEBUG_SEPARATOR_LINE cout<<"=================\n"
#else
#define DEBUG(X) 0
#define DEBUG_ENDL 0
#define DEBUG_SEPARATOR_LINE 0
#endif
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
#define DEBUG_ENDL_S(S) ((S).size() ? "\n" : "") << flush;
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
void debug_func_preffix(const string &s) { if(s.size()) cout << s << " = "; }
template <typename T>
void debug_func(const T &t, const string &s = "") {
    debug_func_preffix(s);
    cout << t << DEBUG_ENDL_S(s);
}
template <typename T, typename U>
void debug_func(const P<T, U> &p, const string &s = "") {
    debug_func_preffix(s);
    cout << "(";
    debug_func(p.first);
    cout << ", ";
    debug_func(p.second);
    cout << ")" << DEBUG_ENDL_S(s);
}
template <typename T>
void debug_func(const V<T> &v, const string &s = "") {
    for(ll i = 0; i < v.size(); i++) {
        string t = s + "[" + to_string(i) + "]";
        debug_func(v[i], t);
    }
}

void init_io() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(30);
}

const ll MOD = 1e9 + 7;
V<char> clis = { 'A', 'C', 'G', 'T' };

bool check(const string &s) {
    bool ok = true;
    for(ll i = 0; i <= s.size() - 3; i++) if(s.substr(i, 3) == "AGC") ok = false;
    for(ll i = 0; i < s.size() - 1; i++) {
        string t = s;
        swap(t[i], t[i + 1]);
        for(ll j = 0; j <= t.size() - 3; j++) if(t.substr(j, 3) == "AGC") ok = false;
    }
    return ok;
}

int main() {
    init_io();
    ll N;
    cin >> N;
    V<string> str;
    ll p = pow(4, min<ll>(N, 5));
    for(ll i = 0; i < p; i++) {
        ll cpy = i;
        string s = "";
        for(ll j = 0; j < min<ll>(N, 5); j++) {
            s += clis[cpy % 4];
            cpy /= 4;
        }
        str.push_back(s);
    }
    
    map<string, ll> id;
    set<string> ngs;
    for(const string &s : str) {
        ll tmp = id.size();
        id[s] = tmp;
        if(!check(s)) ngs.insert(s);
    }

    if(N <= 5) {
        cout << str.size() - ngs.size() << endl;
        return 0;
    }

    VV<ll> dp(N + 10, V<ll>(1024, 0));
    dp[5] = V<ll>(1024, 1);
    for(const auto &s : ngs) dp[5][id[s]] = 0;
    for(ll i = 5; i < N; i++) {
        for(ll j = 0; j < 1024; j++) {
            string s = str[j];
            for(char c : clis) {
                string t = s + c;
                t = t.substr(1, 5);
                if(ngs.find(t) == ngs.end()) (dp[i + 1][id[t]] += dp[i][id[s]]) %= MOD;
            }
        }
    }
    cout << accumulate(ALL(dp[N]), 0ll) % MOD << endl;
    return 0;
}




Measured memory_bytes: 1280