#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);
const long long mod = 1000000007;

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
void print(void) { cout << endl; }
template <class Head> void print(Head&& head) { cout << head; print(); }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); }

VS str;
void dfs(string s) {
	if (sz(s) == 3) {
		str.pb(s);
	}
	else {
		dfs(s + "A");
		dfs(s + "C");
		dfs(s + "G");
		dfs(s + "T");
	}
}

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

	vector<map<string, long long>> dp(n + 1);

	//dp[3]
	dfs("A"); dfs("C"); dfs("G"); dfs("T");
	for (auto sss : str) {
		if (sss == "AGC" || sss == "ACG" || sss == "GAC")dp[3][sss] = 0;
		else dp[3][sss] = 1;
	}


	//dp[4]-dp[n]
	for (int i = 4; i <= n; i++) {
		for (auto aaa : dp[i - 1]) {
			string s = aaa.first;
			long long nu = aaa.second;

			string e2 = s.substr(1, 2);
			if (e2 == "AC") {
				dp[i]["ACA"] += nu;
				dp[i]["ACC"] += nu;
				dp[i]["ACT"] += nu;
				dp[i]["ACA"] %= mod;
				dp[i]["ACC"] %= mod;
				dp[i]["ACT"] %= mod;
			}
			else if (e2 == "GA") {
				dp[i]["GAA"] += nu;
				dp[i]["GAG"] += nu;
				dp[i]["GAT"] += nu;
				dp[i]["GAA"] %= mod;
				dp[i]["GAG"] %= mod;
				dp[i]["GAT"] %= mod;
			}
			else if (e2 == "AG") {
				dp[i]["AGA"] += nu;
				dp[i]["AGG"] += nu;
				dp[i]["AGT"] += nu;
				dp[i]["AGA"] %= mod;
				dp[i]["AGG"] %= mod;
				dp[i]["AGT"] %= mod;
			}
			else if (s == "AGG") {
				dp[i]["GGA"] += nu;
				dp[i]["GGG"] += nu;
				dp[i]["GGT"] += nu;
				dp[i]["GGA"] %= mod;
				dp[i]["GGG"] %= mod;
				dp[i]["GGT"] %= mod;
			}
			else if (s == "AGT") {
				dp[i]["GTA"] += nu;
				dp[i]["GTG"] += nu;
				dp[i]["GTT"] += nu;
				dp[i]["GTA"] %= mod;
				dp[i]["GTG"] %= mod;
				dp[i]["GTT"] %= mod;
			}
			else if (s == "ATG") {
				dp[i]["TGA"] += nu;
				dp[i]["TGG"] += nu;
				dp[i]["TGT"] += nu;
				dp[i]["TGA"] %= mod;
				dp[i]["TGG"] %= mod;
				dp[i]["TGT"] %= mod;
			}
			else {
				dp[i][e2 + "A"] += nu;
				dp[i][e2 + "C"] += nu;
				dp[i][e2 + "G"] += nu;
				dp[i][e2 + "T"] += nu;
				dp[i][e2 + "A"] %= mod;
				dp[i][e2 + "C"] %= mod;
				dp[i][e2 + "G"] %= mod;
				dp[i][e2 + "T"] %= mod;
			}
		}
		//print(i, dp[i]);
	}


	//Output
	long long ans = 0;
	for (auto aaa : dp[n]) {
		ans += aaa.second;
	}
	ans %= mod;
	Cout(ans);
}

Measured memory_bytes: 896