#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#ifndef LOCAL
struct ostdmy{template<class T>ostdmy&operator<<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
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(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<ll MODULO=MOD> // modulo should be prime
class intm{
private:
    ll a;
    constexpr static ll _nl(const ll&a){return a%MODULO;}
    //constexpr static ll _nl(const ll&a){return a>=0?a%MODULO:MODULO-(-a)%MODULO;}
public:
    constexpr static ll phi(){
                return MODULO-1;
    }
    intm():a(0){}
    intm(const ll&a):a(_nl(a)){}
    intm(const intm&o):a((ll)o){}

    inline intm&operator=(const ll&o){a=_nl(o);return*this;};
    inline operator ll()const{return a;}
    inline operator bool()const{return (bool)a;}

    inline intm&operator+=(const ll&o){a=_nl(a+_nl(o));return*this;};
    inline intm&operator+=(const intm&o){return*this+=(ll)o;};
    template<class T>const intm operator+(const T&o)const{intm b(a);return b+=o;}

    inline const intm operator+()const{return *this;}
};

template<ll M>ostream&operator<<(ostream&o,const intm<M>&v){return o<<(ll)v;}
template<ll M>const istream&operator>>(istream&i,intm<M>&v){ll b;i>>b;v=b;return i;}
const char*acgt="ACGT";
/*const string ntos(intm<> a){
    string ret;
    REPR(i,3){
        ret+=acgt[(a&(3<<(i*2)))>>(i*2)];
    }
    return ret;
}*/
inline int app(int moto,int a){
    return ((moto<<2)&63) | a;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n;
    cin>>n;
    vector<intm<MOD>> dp(64) // 4^3
            ,bk(64);
    // 0:A
    // 1:C
    // 2:G
    // 3:T

    dp[63]=1;
    REP(i,n){
        cerr<<"Yay"<<endl;
        bk=vector<intm<MOD>>(dp);
        REP(j,64)dp[j]=0;
        cerr<<"Yayy"<<endl;
        REP(j,64){
            dp[app(j,0)]+=bk[j];
            dp[app(j,3)]+=bk[j];

            if((j&60)!=8 &&
                (j&15)!=2 &&
                (j&51)!=2 &&
                (j&15)!=8)dp[app(j,1)]+=bk[j]; // C
            if((j&15)!=1)dp[app(j,2)]+=bk[j]; // G
        }
        cerr<<"Yayyy"<<endl;
        /*REP(j,64){
            dp[j]%=MOD;
            //cerr<<ntos(j)<<':'<<dp[j]<<endl;
        }*/
        //cerr<<"\n\n\n\n\n\n\n\n";

    }
    cout<<accumulate(all(dp), intm<MOD>(0))<<endl;
    return 0;
}


Measured memory_bytes: 256