#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }




int main() {
	int n;
	cin >> n;

	vector<map<string, int>> dp(n);
	dp[0]["A"] = 1;
	dp[0]["C"] = 1;
	dp[0]["G"] = 1;
	dp[0]["T"] = 1;
	dp[1]["AA"] = 1;
	dp[1]["AC"] = 1;
	dp[1]["AG"] = 1;
	dp[1]["CA"] = 1;
	dp[1]["CC"] = 1;
	dp[1]["CG"] = 1;
	dp[1]["GA"] = 1;
	dp[1]["GC"] = 1;
	dp[1]["GG"] = 1;
	dp[1]["AT"] = 1;
	dp[1]["CT"] = 1;
	dp[1]["GT"] = 1;
	dp[1]["TT"] = 1;
	dp[1]["TA"] = 1;
	dp[1]["TC"] = 1;
	dp[1]["TG"] = 1;

	string acgt = "ACGT";

	FOR(i,1, n-1) {

		for (auto itr = dp[i].begin(); itr != dp[i].end(); ++itr) {
			auto key = itr->first;      // キーを表示
			auto value = itr->second;   // 値を表示
			
			if (key.size() == 3) {
				string newKey0 = "";
				newKey0.push_back(key[1]);
				newKey0.push_back(key[2]);
				rep(j, 4) {
					auto newKey = newKey0;
					auto back = acgt[j];
					if (back == 'C') {
						if ((newKey == "AG")
							|| (key[0] == 'A' && key[1] == 'G')
							|| (key[0] == 'A' && key[2] == 'G')
							|| (newKey == "GA")
							) {
						}
						else {
							newKey.push_back(back);
							dp[i + 1][newKey] += value;
							dp[i + 1][newKey] = dp[i + 1][newKey] % mod;
						}
					}
					else if (back == 'G') {
						if (newKey == "AC")
						{
						}
						else {
							newKey.push_back(back);
							dp[i + 1][newKey] += value;
							dp[i + 1][newKey] = dp[i + 1][newKey] % mod;
						}
					}
					else {

						newKey.push_back(back);
						dp[i + 1][newKey] += value;
						dp[i + 1][newKey] = dp[i + 1][newKey] % mod;
					}
				}

			}
			else {
				string newKey0 = key;
				rep(j, 4) {
					auto newKey = newKey0;
					auto back = acgt[j];
					if (back == 'C') {
						if ((newKey == "AG")
							|| (newKey == "GA")
							) {
						}
						else {
							newKey.push_back(back);
							dp[i + 1][newKey] += value;
							dp[i + 1][newKey] = dp[i + 1][newKey] % mod;
						}
					}
					else if (back == 'G') {
						if (newKey == "AC")
						{
						}
						else {
							newKey.push_back(back);
							dp[i + 1][newKey] += value;
							dp[i + 1][newKey] = dp[i + 1][newKey] % mod;
						}
					}
					else {

						newKey.push_back(back);
						dp[i + 1][newKey] += value;
						dp[i + 1][newKey] = dp[i + 1][newKey] % mod;
					}
				}
			}

		}
		
	}

	ll ans = 0;
	for (auto itr = dp[n-1].begin(); itr != dp[n-1].end(); ++itr) {
		auto key = itr->first;      // キーを表示
		auto value = itr->second;
		ans += value;
	}
	cout << ans % mod << endl;

	return 0;
}



Measured memory_bytes: 896