import qualified Data.Map as Map

m1=1000000007
t="AGC"
f::String->Bool
f (a:b:c:[])=((a:b:c:[])/=t && (b:a:c:[])/=t && (a:c:b:[]/=t))

f2::String->Bool
f2 (a:b:c:d:[])=((a:b:d:[])/=t && ((c:b:d:[])/=t) && (b:c:d:[])/=t && (b:d:c:[])/=t&&(a:c:d:[])/=t)

f3::Int->Int->Int
f3 a b=mod (a+b) m1

g::Int->Map.Map String Int->Int
g 0 ms=mod (sum $ Map.elems ms) m1
g k ms=g (k-1) (Map.fromListWith (f3) [(b:c:d:[],c1)|(a:b:c:[],c1)<-(Map.toList ms),d<-"AGCT",f2 (a:b:c:d:[])])

main = do
       t<-getLine
       let n=read t::Int
           s="AGCT"
           ms=Map.fromList [(e1:e2:e3:[],1)|e1<-s,e2<-s,e3<-s,f (e1:e2:e3:[])]
       print $ g (n-3) ms