MOD = (10 ** 9) + 7

C = ['A','G','C','T']
R = /(AGC|ACG|GAC|A.GC|AG.C)/

W4 = C.product(C,C,C).map(&:join).reject{|w4| R.match?(w4) }.sort

INDEX = {}
W4.each_with_index do |w4, i|
  INDEX[w4] = i
end

A = W4.map do |w4|
  w3 = w4[1,3]
  C.map{|c| INDEX["#{w3}#{c}"] }
end

N = gets.to_i
if N == 3
  puts  C.product(C,C).map(&:join).reject{|w3| R.match?(w3) }.size
elsif N == 4
  puts W4.size
else
  dp = Array.new(N + 1){ Array.new(W4.size, 0) }
  W4.each_index{|i| dp[4][i] = 1 }
  
  (4 ... N).each do |n|
    W4.each_index do |i|
      C.each_index do |j|
        i_ = A[i][j]
        dp[n + 1][i_] = (dp[n + 1][i_] + dp[n][i]) % MOD if i_
      end
    end
  end
  ans = dp[N].inject(0, &:+) % MOD
  puts ans
end


