using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using System.Xml.Schema;
using System.ComponentModel.DataAnnotations;
using System.Security.Cryptography;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var dp = new long[N + 1, 4, 4, 4];//一つ前の文字がA,G,C,T、二つ前の文字がA,G,C,T
            var A = 0;
            var G = 1;
            var C = 2;
            var T = 3;
            //N文字目までAGCとならない場合、N+1文字目が
            //A,T→AGCにならない
            //G→1つ前がC,2つ前がAならAGC
            //C→1つ前がG,2つ前がA
            //   1つ前がG,        ,3つ前がA
            //   1つ前がA,2つ前がG
            //            2つ前がG,3つ前がA

            for (var p1 = 0; p1 < 4; ++p1)//1つ前の文字
                for (var p2 = 0; p2 < 4; ++p2)//2つ前の文字
                    for (var p3 = 0; p3 < 4; ++p3)
                        dp[3, p1, p2, p3] = 1;
            dp[3, C, G, A] = 0;
            dp[3, C, A, G] = 0;
            dp[3, G, C, A] = 0;
            for (var i = 3; i < N; ++i)
            {
                for (var p1 = 0; p1 < 4; ++p1)//1つ前の文字
                    for (var p2 = 0; p2 < 4; ++p2)//2つ前の文字
                        for (var p3 = 0; p3 < 4; ++p3)//3つ前の文字
                        {
                            dp[i + 1, A, p1, p2] += dp[i, p1, p2, p3];
                            if (!(p1 == C && p2 == A))
                                dp[i + 1, G, p1, p2] += dp[i, p1, p2, p3];
                            if (!
                                (
                                (p1 == G && p2 == A) || (p1 == A && p2 == G) ||
                                (p1 == G && p3 == A) || (p2 == G && p3 == A)
                                ))
                                dp[i + 1, C, p1, p2] += dp[i, p1, p2, p3];
                            dp[i + 1, T, p1, p2] += dp[i, p1, p2, p3];
                            for (var t = 0; t < 4; ++t)
                                dp[i + 1, t, p1, p2] %= Mod;
                        }
            }
            var ans = 0L;
            for (var p1 = 0; p1 < 4; ++p1)//1つ前の文字
                for (var p2 = 0; p2 < 4; ++p2)//2つ前の文字
                    for (var p3 = 0; p3 < 4; ++p3)
                        ans = (ans + dp[N, p1, p2, p3]) % Mod;
            WriteLine(ans);

        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 28236