#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cstring>

using namespace std;

typedef long long i64;
typedef unsigned long long u64;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << x << endl
#else
#define debug(...)
#endif

#define REP(i,n) for(int i=0; i<n; ++i)

int n;

map<pair<int,string>, int> mp;
#define PAIR(x,y) pair<int,string>(x,y)


int dfs(int k, string s){
       int m = 0;
       string s3 = s.size() >=3 ? s.substr(s.size()-3) : "";
       auto it = mp.find(PAIR(k,s3));
       if (it != mp.end() && s3 != "")
               return it->second;

        if (k == 0) return 1;
        int sl = s.size();

        if (sl <= 1) {
                m += dfs(k-1, s + "A");
                m %= 1000000007;
                m += dfs(k-1, s + "G");
                m %= 1000000007;
                m += dfs(k-1, s + "C");
                m %= 1000000007;
                m += dfs(k-1, s + "T");
                m %= 1000000007;
                return m;
        }
        // *AGC
        if (s[sl-2] == 'A' && s[sl-1] == 'G') {
                m += dfs(k-1, s + "A");
                m %= 1000000007;
                m += dfs(k-1, s + "G");
                m %= 1000000007;
                m += dfs(k-1, s + "T");
                m %= 1000000007;
                mp[PAIR(k, s3)] = m;
                return m;
        }
        // *ACG
        if (s[sl-2] == 'A' && s[sl-1] == 'C') {
                m += dfs(k-1, s + "A");
                m %= 1000000007;
                m += dfs(k-1, s + "C");
                m %= 1000000007;
                m += dfs(k-1, s + "T");
                m %= 1000000007;
                mp[PAIR(k, s3)] = m;
                return m;
        }
        // *GAC
        if (s[sl-2] == 'G' && s[sl-1] == 'A') {
                m += dfs(k-1, s + "A");
                m %= 1000000007;
                m += dfs(k-1, s + "G");
                m %= 1000000007;
                m += dfs(k-1, s + "T");
                m %= 1000000007;
                mp[PAIR(k, s3)] = m;
                return m;
        }
        // AG*C
        if (sl >= 3 && s[sl-3] == 'A' && s[sl-2] == 'G') {
                m += dfs(k-1, s + "A");
                m %= 1000000007;
                m += dfs(k-1, s + "G");
                m %= 1000000007;
                m += dfs(k-1, s + "T");
                m %= 1000000007;
                mp[PAIR(k, s3)] = m;
                return m;
        }
        // A*GC
        if (sl >= 3 && s[sl-3] == 'A' && s[sl-1] == 'G') {
                m += dfs(k-1, s + "A");
                m %= 1000000007;
                m += dfs(k-1, s + "G");
                m %= 1000000007;
                m += dfs(k-1, s + "T");
                m %= 1000000007;
                mp[PAIR(k, s3)] = m;
                return m;
        }
        m += dfs(k-1, s + "A");
        m %= 1000000007;
        m += dfs(k-1, s + "G");
        m %= 1000000007;
        m += dfs(k-1, s + "C");
        m %= 1000000007;
        m += dfs(k-1, s + "T");
        m %= 1000000007;
        mp[PAIR(k, s3)] = m;
        return m;
}


int main(){
        cin.tie(0);
        ios::sync_with_stdio(false);

        cin >> n;

        cout << dfs(n, "") << endl;


        return 0;
}


Measured memory_bytes: 1024