// Original C++ solution (slower):
#include<iostream>

#include<vector>

#include<string>

#include<algorithm>

using namespace std;

typedef long long ll;



int main(){

    int N;

    cin >> N;



    ll div = 1000000007;

    // vector<ll> ret = { 4, 3, 4, 4,

    //                     4, 4, 3, 4,

    //                     4, 3, 4, 4,

    //                     4, 4, 4, 4 };

    vector<ll> ret(64);

    vector<string> retstr(64);

    vector<string> strmap = {"A", "C", "G", "T"};

    vector<string> error = {"AGC" , "ACG", "GAC"};

    vector<string> error2 = {"AGC"};

    for(size_t i = 0; i < 64; i++)

    {

        retstr[i] = strmap[i/16] + strmap[i%16/4] + strmap[i%4];

        //if (retstr[i] != "AGC" && retstr[i] != "ACG" &&retstr[i] != "GAC")

        if (find(error.begin(), error.end(), retstr[i]) == error.end())

            ret[i] = 1;

        else

            ret[i] = 0;

    }

    vector<ll> ret_temp(64);

    ll matrix[64][64];

    for(size_t i = 0; i < 64; i++)

    {

        for(size_t j = 0; j < 64; j++)

        {

            if(retstr[i].substr(0,2) == retstr[j].substr(1,2)){

                string substr1 = retstr[j].substr(0,2) + retstr[i].substr(2,1);

                string substr2 = retstr[j].substr(0,1) + retstr[i].substr(1,2);

                if((find(error.begin(), error.end(), retstr[i]) != error.end()) ||

                (find(error2.begin(), error2.end(), substr1) != error2.end()) ||

                (find(error2.begin(), error2.end(), substr2) != error2.end()))

                    matrix[i][j] = 0;

                else

                    matrix[i][j] = 1;

            }

            else

                matrix[i][j] = 0;

        }

    }

    for(size_t i = 3; i < N; i++)

    {

        ret_temp = vector<ll>(64, 0);

        for(size_t j = 0; j < 64; j++)

        {

            for(size_t k = 0; k < 64; k++)

            {

                ret_temp[j] += (matrix[j][k] * ret[k]);

            }

        }

        for(size_t l = 0; l < 64; l++)

        {

            ret[l] = ret_temp[l] % div;

        }

    }



    ll ret_total=0;

    for(auto reti : ret){

        ret_total += reti % div;

    }

    ret_total %= div;

    cout << ret_total << endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include "bits/stdc++.h"

using namespace std;

using ll     = long long;

using pii    = pair<int, int>;

using pll    = pair<ll, ll>;

using vi     = vector<int>;

using vl     = vector<ll>;

using vvi    = vector<vi>;

using vvl    = vector<vl>;

const ll INF = 1LL << 60;

const ll MOD = 1000000007;

template <class T>

bool chmax(T &a, const T &b) {

    return (a < b) ? (a = b, 1) : 0;

}

template <class T>

bool chmin(T &a, const T &b) {

    return (b < a) ? (a = b, 1) : 0;

}

template <class C>

void print(const C &c, std::ostream &os = std::cout) {

    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));

    os << std::endl;

}



int main() {

    int n;

    cin >> n;

    vector<vector<vvl>> dp(n + 1, vector<vvl>(4, vvl(4, vl(4, 0))));

    for (int i = 0; i < 4; ++i) {

        for (int j = 0; j < 4; ++j) {

            for (int k = 0; k < 4; ++k) {

                if ((i == 0 && j == 1 && k == 2) || (i == 1 && j == 0 && k == 2) || (i == 0 && j == 2 && k == 1))

                    continue;

                dp[3][i][j][k] = 1;

            }

        }

    }

    // 0a 1c 2g 3t

    for (int i = 4; i <= n; ++i) {

        for (int j = 0; j < 4; ++j) {

            for (int k = 0; k < 4; ++k) {

                for (int l = 0; l < 4; ++l) {

                    for (int m = 0; m < 4; ++m) {

                        if (k == 0 && l == 1 && m == 2)

                            continue;

                        if (j == 0 && k == 1 && m == 2)

                            continue;

                        if (k == 1 && l == 0 && m == 2)

                            continue;

                        if (k == 0 && l == 2 && m == 1)

                            continue;

                        if (j == 0 && l == 1 && m == 2)

                            continue;

                        dp[i][k][l][m] = (dp[i][k][l][m] + dp[i - 1][j][k][l]) % MOD;

                    }

                }

            }

        }

    }

    ll ret = 0;

    for (int j = 0; j < 4; ++j) {

        for (int k = 0; k < 4; ++k) {

            for (int l = 0; l < 4; ++l) {

                ret = (ret + dp[n][j][k][l]) % MOD;

            }

        }

    }

    cout << ret << "\n";

    return 0;

}

// Fastest known solution for this problem: