M=10**9+7
dp={"TTT"=>1}
gets.to_i.times do
  nex=Hash.new{|h,k|h[k]=0}
  dp.each do |k,v|
    "AGCT".chars.each do |c|
      s=k+c
      next if s.match(/AGC|GAC|ACG|A.GC|AG.C/)
      s=s[1..-1]
      nex[s]+=v
      nex[s]%=M
    end
  end
  dp=nex
end
p dp.values.inject(:+)%M