//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

struct Mod {
    static ll BASE;
    ll value = 0;
    static ll residue(ll value) { return (value % BASE + BASE) % BASE; }
    Mod() : Mod(0) {}
    Mod(ll value)
    : value(residue(value)) {}
    Mod operator+(const Mod& rhs) const { return Mod(value + rhs.value); }
    void operator+=(const Mod& rhs) { *this = *this + rhs; }
    Mod operator-(const Mod& rhs) const { return Mod(value - rhs.value); }
    void operator-=(const Mod& rhs) { *this = *this - rhs; }
    Mod operator*(const Mod& rhs) const { return Mod(value * rhs.value); }
    void operator*=(const Mod& rhs) { *this = *this * rhs; }
};
ll Mod::BASE = 1000000007;

int main() {
    ll N;
    cin >> N;
    string chars = "ACGT";
    vector<string> ngs;
    ngs.push_back("AGC");
    for (char c : chars) {
        ngs.push_back("A" + string(&c, 1) + "GC");
    }
    ngs.push_back("GAC");
    ngs.push_back("ACG");
    for (char c : chars) {
        ngs.push_back("AG" + string(&c, 1) + "C");
    }
    unordered_set<string> ngs_set;
    for (string ng : ngs) {
        ngs_set.insert(ng);
    }
    unordered_set<string> states;
    for (string ng : ngs) {
        for (ll n = 0; n < ng.size(); n++) {
            string prefix = ng.substr(0, n);
            if (ngs_set.find(prefix) == ngs_set.end()) {
                states.insert(prefix);
            }
        }
    }
    states.insert("$");
    vector<unordered_map<string, string>> transit(4);
    for (ll c = 0; c < chars.size(); c++) {
        for (string state : states) {
            if (state == "$") {
                transit[c][state] = "$";
                continue;
            }
            string next = state + string(&chars[c], 1);
            for (ll n = next.size(); n >= 0; n--) {
                string next_suffix = next.substr(next.size() - n, n);
                if (ngs_set.find(next_suffix) != ngs_set.end()) {
                    transit[c][state] = "$";
                    break;
                }
                auto it = states.find(next_suffix);
                if (it != states.end()) {
                    transit[c][state] = *it;
                    break;
                }
            }
        }
    }
#ifdef DEBUG
    for (ll c = 0; c < 4; c++) {
        for (const auto& kv : transit[c]) {
            cout << "transit[" << chars[c] << "][" << kv.first << "] = " << kv.second << endl;
        }
    }
#endif
    vector<unordered_map<string, Mod>> dp(N+1);
    dp[0][""] = 1;
    for (ll n = 0; n < N; n++) {
        for (string state : states) {
            for (ll c = 0; c < 4; c++) {
                string next = transit[c][state];
                dp[n+1][next] += dp[n][state];
            }
        }
    }
    Mod ans = 0;
    for (const auto& kv : dp[N]) {
        if (kv.first != "$") {
            ans += kv.second;
        }
    }
    cout << ans.value << endl;
}



Measured memory_bytes: 384