#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

bool check(string str){
  str.resize(4);
  if(str=="ACGC") return false;
  if(str=="AGGC") return false;
  if(str=="ATGC") return false;
  if(str=="AGAC") return false;
  if(str=="AGGC") return false;
  if(str=="AGTC") return false;
  str.resize(3);
  if(str=="AGC") return false;
  if(str=="ACG") return false;
  if(str=="GAC") return false;
  return true;
}

char num_to_char(int k){
  switch(k){
    case 0:
      return 'A';
    case 1:
      return 'C';
    case 2:
      return 'G';
    case 3:
      return 'T';
  }
  fprintf(stderr, "unexpected erorr\n");
  exit(0);
}

string num_to_str(int k){
  char a1 = num_to_char(k/16);
  k %= 16;
  char a2 = num_to_char(k/4);
  k %= 4;
  char a3 = num_to_char(k);

  string str = "";
  str += a1;
  str += a2;
  str += a3;
  return str;
}

ll char_to_num(char ch){
  if(ch=='A') return 0;
  if(ch=='C') return 1;
  if(ch=='G') return 2;
  if(ch=='T') return 3;
  return -1;
}

ll str_to_num(string str){
  str.resize(3);
  int a1 = char_to_num(str[0]);
  int a2 = char_to_num(str[1]);
  int a3 = char_to_num(str[2]);
  return a1*16 + a2*4 + a3;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  cin >> N;

  vvll begin_by(4*4*4, vll(N+1, 0));
  // A=0, C=1, G=2, T=3
  // forbidden : AGC, ACG, GAC, ACGC, AGGC, ATGC, AGAC, AGGC, AGTC

  if(N==0){
    cout << 0 << "\n";
    return 0;
  }
  if(N==1){
    cout << 4 << "\n";
    return 0;
  }
  if(N==2){
    cout << 16 << "\n";
    return 0;
  }

  REP(i, 4*4*4){
    if(!check(num_to_str(i))) continue;
    begin_by[i][3] = 1;
  }

  FOR(n, 4, N+1){
    REP(i, 64){
      string str_tmp = num_to_str(i);
      string str_next1 = "A" + str_tmp;
      if(check(str_next1))
        begin_by[str_to_num(str_next1)][n] += begin_by[i][n-1];
        begin_by[str_to_num(str_next1)][n] %= MOD;
      string str_next2 = "C" + str_tmp;
      if(check(str_next2))
        begin_by[str_to_num(str_next2)][n] += begin_by[i][n-1];
        begin_by[str_to_num(str_next2)][n] %= MOD;
      string str_next3 = "G" + str_tmp;
      if(check(str_next3))
        begin_by[str_to_num(str_next3)][n] += begin_by[i][n-1];
        begin_by[str_to_num(str_next3)][n] %= MOD;
      string str_next4 = "T" + str_tmp;
      if(check(str_next4))
        begin_by[str_to_num(str_next4)][n] += begin_by[i][n-1];
        begin_by[str_to_num(str_next4)][n] %= MOD;
    }
  }

  ll ans = 0;
  REP(i, 64){
    ans += begin_by[i][N]%MOD;
  }

  cout << ans%MOD << "\n";


  return 0;
}

Measured memory_bytes: 256