N = gets.to_i

MOD = (10 ** 9) + 7
C = ['A','G','C','T']
R = /(AGC|ACG|GAC|A.GC|AG.C)/
W3 = C.product(C,C).map(&:join).reject{|w3| R =~ w3 }

if N == 3
  puts  W3.size
  exit
end

INDEX = W3.each_with_index.to_h
A = W3.map do |w3|
  C.map do |c| 
    w4 = w3 + c
    R =~ w4 ? nil : INDEX[w3[1,2] + c]
  end
end
dp = (4 .. N).inject(Array.new(W3.size,1)) do |prev, n|
  current = Array.new(W3.size, 0) 
  prev.each_with_index do |v, w3|
    C.each_index do |c|
      w3_ = A[w3][c]
      if w3_
        current[w3_] += v
        current[w3_] %= MOD
      end
    end
  end
  current
end
puts dp.inject(&:+) % MOD
