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