#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(const size_t n, const size_t m, const T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; }return 0; }
constexpr ll pow2(const int n) { return 1ll << n; }
constexpr int INF = 1 << 28; constexpr ll LINF = 1ll << 60;
constexpr int MAX = 1e5 + 5; constexpr int MOD = 1e9 + 7; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }; constexpr int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;
// 1. 問題よくよめえええええええええええええええええええええええええ
// 2. intオーバーフロー << * + あたり
// 3. 落ち着け

// A0C1G2T3
// AGC:00 10 01 = 8 + 1 = 9
// ACG:00 01 10 = 4 + 2 = 6
// GAC:10 00 01 = 32 + 1 = 33

int N;

int main() {
    cin >> N;

    vv<ll> dp = vvec(N + 1, 64, (ll)0);
    rep(i, 64) {
        if (i == 9 || i == 6 || i == 33) {
            dp[3][i] = 0;
        }
        else {
            dp[3][i] = 1;
        }
    }

    rep(i, 3, N) {
        rep(j, 64) {
            int r = j % 16; // 後ろ2

            //rep(k, 4) {
            //    if (k == 0 ) {
            //        if ()

            //        int to = (r << 2) + k;
            //        dp[i + 1][to] += dp[i][j];
            //        dp[i + 1][to] %= MOD;
            //    }
            //    else if (k == 1 && (r == 2 || r == 8 || (j >> 2) == 2)) {
            //        
            //    }
            //    else if (k == 2 && r == 1) {

            //    }
            //    else {
            //        int to = (r << 2) + k;
            //        dp[i + 1][to] += dp[i][j];
            //        dp[i + 1][to] %= MOD;
            //    }
            //}
           
            if (j == 9 || j == 6 || j == 33) {
                // AGC ACG GAC
                int c = 0;
            }
            else if (r == 2 || r == 8 || (j >> 2) == 2 || ((j >> 4) == 0 && (r % 4) == 2)) {
                // A00 問題なし
                // C01
                // xAG xGA AGx
                rep(k, 4) {
                    if (k != 1) {
                        int to = (r << 2) + k;
                        dp[i + 1][to] += dp[i][j];
                        dp[i + 1][to] %= MOD;
                    }
                }
            }
            else if (r == 1) {
                // G10
                // xAC AxG
                rep(k, 4) {
                    if (k != 2) {
                        int to = (r << 2) + k;
                        dp[i + 1][to] += dp[i][j];
                        dp[i + 1][to] %= MOD;
                    }
                }
                // T11 問題なし
            }
            else {
                rep(k, 4) {
                    int to = (r << 2) + k;
                    dp[i + 1][to] += dp[i][j];
                    dp[i + 1][to] %= MOD;
                }
            }

            int a = 0;
        }
        int b = 0;
    }

    ll ans = 0;
    rep(i, 64) {
        ans += dp[N][i];
        ans %= MOD;
    }
    write(ans);
}

Measured memory_bytes: 256