#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include <iostream>
//#include <algorithm>
#include <limits>
#include<string>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
vector<vector<vector<double>>> dp;
//cout <<fixed << setprecision(10)<< ans;で、小数精度10桁にできる
/*void printdp(int N,ll Vmax){
	rep(i,N+1){
		for(ll j=0;j<Vmax+1;j++){
			if(dp[i][j]==llMAX)continue;
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;
	return;
}*/

int nary_k(int num,int n,int k){//numをn進数で表した時のk桁目
  return  num/((int)pow(n,k)) - (num/((int)pow(n,k+1)))*n;
}
string convert(int i){
	string a[3];
	rep(k,3){
		int num = nary_k(i,4,k);
		//cout << pow(4,k) << "ddd" << endl;
		//cout << (i/((int)pow(4,k+1)))*4 << " "  <<i/((int)pow(4,k))<<endl;
		if(num==0){
			a[2-k]='A';
		}else if(num==1){
			a[2-k] = 'C';
		}else if(num==2){
			a[2-k] = 'G';
		}else if(num==3){
			a[2-k] = 'T';
		}else{
			cout <<"ERROR"<<endl;
			//return "d";
		}
	}
	//cout << a << endl;
	string result = a[0]+a[1]+a[2];
	return result;
}
string convert2(int i){
	string a[4];
	rep(k,4){
		int num = nary_k(i,4,k);
		//cout << pow(4,k) << "ddd" << endl;
		//cout << (i/((int)pow(4,k+1)))*4 << " "  <<i/((int)pow(4,k))<<endl;
		if(num==0){
			a[3-k]='A';
		}else if(num==1){
			a[3-k] = 'C';
		}else if(num==2){
			a[3-k] = 'G';
		}else if(num==3){
			a[3-k] = 'T';
		}else{
			cout <<"ERROR"<<endl;
			//return "d";
		}
	}
	//cout << a << endl;
	string result = a[0]+a[1]+a[2]+a[3];
	return result;
}
int main(void){
	int N,K,tmp;
	cin >> N;
	ll **dp=(ll**)malloc(64*sizeof(long long*));
	rep(i,64){
		dp[i] = (ll*)malloc((N+1)*sizeof(long long));
		if(dp[i]==NULL){
			cout << "ERROR";
			return 0;
		}
	}
	rep(i,64){
		rep(j,N+1){
			dp[i][j] =0;
		}
	}
	rep(i,64){
		//cout << convert(i) << endl;
		if(convert(i)=="AGC"||convert(i)=="ACG"||convert(i)=="GAC"){
			dp[i][1]=0;
			//cout << "ddd";
		}else if(convert(i)=="d"){
			return 0;
		}else{
			//cout << convert(i) << endl;
			dp[i][1] =1;
		}
	}
	for(int i=2;i<=N-2;i++){
		//cout << "o  " << i << endl;
		rep(j,64){
			int newn = (j%16)*4;
			rep(k,4){
				if(newn+k>=64){
					cout << "ERROR";
					return 0;
				}
				if(convert(newn+k)=="AGC"||convert(newn+k)=="GAC"||convert(newn+k)=="ACG"){
					dp[newn+k][i]=0;
					//cout << "p";
				}else if(convert2(j*4+k)=="ACGC"||convert2(j*4+k)=="ATGC"||convert2(j*4+k)=="AGGC"){
					//cout << convert2(j*4+k) << "%" << j*4+k<< endl;
					//0ではなく、今回は飛ばすということ
					//dp[newn+k][i]=0;
					//cout << "s";
				}else if(convert2(j*4+k)=="AGAC"||convert2(j*4+k)=="AGTC"||convert2(j*4+k)=="AGGC"||convert2(j*4+k)=="AGCC"){
					//cout << convert2(j*4+k) << "%" << j*4+k<< endl;
					//0ではなく、今回は飛ばすということ
					//dp[newn+k][i]=0;
					//cout << "s";
				}else{
					dp[newn+k][i]+=dp[j][i-1];
				}
			}
		}
		rep(j,64){
			dp[j][i]%=1000000007;
		}
	}
	ll sum=0;
	for(int i=0;i<64;i++){
		sum+=dp[i][N-2];
		sum =sum%(ll)1000000007;
		//cout << convert(i) << "fff" <<dp[i][N-2] << endl;
	}
	cout << sum%(ll)1000000007;
	return 0;
}

Measured memory_bytes: 256