CHARS = ['A', 'G', 'C', 'T']
PROHIBITED = ['AGC', 'ACG', 'GAC', 'ACGC', 'AGGC', 'ATGC', 'AGAC', 'AGGC', 'AGTC']
MOD = 10**9 + 7
N = gets.to_i

def accept(last4)
  !PROHIBITED.any?{|word| last4.include? word }
end

MEMO = []
def patterns(len, last3)
  return MEMO[len][last3] if !MEMO[len].nil? && MEMO[len][last3]
  return 1 if len == N
  result = 0
  CHARS.each do |char|
    last4 = last3 + char
    next if !accept(last4)
    result = (result + patterns(len+1, last4[1,3])) % MOD
  end
  MEMO[len] = {} if MEMO[len].nil?
  MEMO[len][last3] = result
  result
end

puts patterns(0, 'xxx')
