#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<cmath>
#include<map>
using namespace std;

int main(){
	int N;
	cin>>N;
	stack<string>s;
	s.push("A");
	s.push("G");
	s.push("C");
	s.push("T");
	string state;
	long ans=0;
	vector<string>arr;
	if(N<=4){
		while(!s.empty()){
			state=s.top();
			s.pop();
			if(state.length()==N){
				//cout<<state<<endl;
				ans++;
				continue;
			}
			else if(state.length()==1){
				s.push(state+'A');
				s.push(state+'G');
				s.push(state+'C');
				s.push(state+'T');
			}
			else{
				if(state[state.length()-2]=='A' && state[state.length()-1]=='G'){
					s.push(state+'A');
					s.push(state+'G');
					s.push(state+'T');
				}
				else if(state[state.length()-2]=='A' && state[state.length()-1]=='C'){
					s.push(state+'A');
					s.push(state+'C');
					s.push(state+'T');
				}
				else if(state[state.length()-2]=='G' && state[state.length()-1]=='A'){
					s.push(state+'A');
					s.push(state+'G');
					s.push(state+'T');
				}
				else if(state.length()>2 && state[state.length()-3]=='A' && state[state.length()-1]=='G'){
					s.push(state+'A');
					s.push(state+'G');
					s.push(state+'T');
				}
				else if(state.length()>2 && state[state.length()-3]=='A' && state[state.length()-2]=='G'){
					s.push(state+'A');
					s.push(state+'G');
					s.push(state+'T');
				}
				else{
					s.push(state+'A');
					s.push(state+'G');
					s.push(state+'C');
					s.push(state+'T');
				}
			}
		}
		cout<<ans<<endl;
	}
	else{
		map<string,long>smap;
		vector<string>arr;
		while(!s.empty()){
			state=s.top();
			s.pop();
			if(state.length()==4){
				//cout<<state<<endl;
				smap[state]=1;
				arr.push_back(state);
				continue;
			}
			else if(state.length()==1){
				s.push(state+'A');
				s.push(state+'G');
				s.push(state+'C');
				s.push(state+'T');
			}
			else{
				if(state[state.length()-2]=='A' && state[state.length()-1]=='G'){
					s.push(state+'A');
					s.push(state+'G');
					s.push(state+'T');
				}
				else if(state[state.length()-2]=='A' && state[state.length()-1]=='C'){
					s.push(state+'A');
					s.push(state+'C');
					s.push(state+'T');
				}
				else if(state[state.length()-2]=='G' && state[state.length()-1]=='A'){
					s.push(state+'A');
					s.push(state+'G');
					s.push(state+'T');
				}
				else if(state.length()>2 && state[state.length()-3]=='A' && state[state.length()-1]=='G'){
					s.push(state+'A');
					s.push(state+'G');
					s.push(state+'T');
				}
				else if(state.length()>2 && state[state.length()-3]=='A' && state[state.length()-2]=='G'){
					s.push(state+'A');
					s.push(state+'G');
					s.push(state+'T');
				}
				else{
					s.push(state+'A');
					s.push(state+'G');
					s.push(state+'C');
					s.push(state+'T');
				}
			}
		}
		/*
		int ans1=0;
		for(int i=0;i<arr.size();++i){
			ans1+=smap[arr[i]];
		}
		cout<<ans1<<endl;
		*/
		string tmp;
		long tmpans;
		for(int i=0;i<N-4;++i){
			for(int j=0;j<arr.size();++j){
				smap[arr[j]]%=(long)pow(10,9)+7;
			}
			map<string,long>smap1;
			for(int j=0;j<arr.size();++j){
				smap1[arr[j]]=smap[arr[j]];
				smap[arr[j]]=0;
			}
			for(int j=0;j<arr.size();++j){
				tmpans=smap1[arr[j]];
				//cout<<tmpans<<endl;
				//cout<<arr[j]<<endl;
				if(arr[j][arr[j].length()-2]=='A' && arr[j][arr[j].length()-1]=='G'){
					//cout<<arr[j]<<endl;
					tmp=(arr[j]+'A').substr(1,4);
					smap[tmp]+=tmpans;
					tmp=(arr[j]+'G').substr(1,4);
					smap[tmp]+=tmpans;
					tmp=(arr[j]+'T').substr(1,4);
					smap[tmp]+=tmpans;
				}
				else if(arr[j][arr[j].length()-2]=='A' && arr[j][arr[j].length()-1]=='C'){
					tmp=(arr[j]+'A').substr(1,4);
					smap[tmp]+=tmpans;
					tmp=(arr[j]+'C').substr(1,4);
					smap[tmp]+=tmpans;
					tmp=(arr[j]+'T').substr(1,4);
					smap[tmp]+=tmpans;
				}
				else if(arr[j][arr[j].length()-2]=='G' && arr[j][arr[j].length()-1]=='A'){
					tmp=(arr[j]+'A').substr(1,4);
					smap[tmp]+=tmpans;
					tmp=(arr[j]+'G').substr(1,4);
					smap[tmp]+=tmpans;
					tmp=(arr[j]+'T').substr(1,4);
					smap[tmp]+=tmpans;
				}
				else if(arr[j][arr[j].length()-3]=='A' && arr[j][arr[j].length()-1]=='G'){
					tmp=(arr[j]+'A').substr(1,4);
					smap[tmp]+=tmpans;
					tmp=(arr[j]+'G').substr(1,4);
					smap[tmp]+=tmpans;
					tmp=(arr[j]+'T').substr(1,4);
					smap[tmp]+=tmpans;
				}
				else if(arr[j][arr[j].length()-3]=='A' && arr[j][arr[j].length()-2]=='G'){
					tmp=(arr[j]+'A').substr(1,4);
					smap[tmp]+=tmpans;
					tmp=(arr[j]+'G').substr(1,4);
					smap[tmp]+=tmpans;
					tmp=(arr[j]+'T').substr(1,4);
					smap[tmp]+=tmpans;
				}
				else{
					tmp=(arr[j]+'A').substr(1,4);
					smap[tmp]+=tmpans;
					tmp=(arr[j]+'C').substr(1,4);
					smap[tmp]+=tmpans;
					tmp=(arr[j]+'G').substr(1,4);
					smap[tmp]+=tmpans;
					tmp=(arr[j]+'T').substr(1,4);
					smap[tmp]+=tmpans;
				}
			}
		}
		for(int i=0;i<arr.size();++i){
			//cout<<arr[i]<<" "<<smap[arr[i]]<<endl;
			ans+=smap[arr[i]];
			ans%=(long)(pow(10,9)+7);
		}
		ans%=(long)(pow(10,9)+7);
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 256