MOD = 7 + 10 ** 9
C = %w/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.to_h
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
  exit(0)
elsif N == 4
  puts W4.size
  exit(0)
end

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|
      dp[n + 1][A[i][j]] += (dp[n][i] % MOD) if A[i][j]
    end
  end
end

puts dp[N].inject(&:+) % MOD
