N = gets.to_i
E = 10 ** 9 + 7
C = %w(A C G T)

$memo = Array.new(N + 1) { Hash.new }

def ok?(last4)
  4.times do |i|
    t = last4.chars
    t[i-1], t[i] = t[i], t[i-1] if i >= 1
    return false if t.join.include?('AGC')
  end
  true
end

def dfs(cur, last3)
  return $memo[cur][last3] if $memo[cur][last3]
  return 1 if cur == N

  ret = 0
  C.each do |c|
    ret += dfs(cur + 1, last3[1, 3] + c) if ok?(last3 + c)
  end

  $memo[cur][last3] = ret
  return ret
end

puts dfs(0, 'TTT') % E