$N = gets.to_i
$MOD = 10 ** 9 + 7
$memo = Array.new($N+1) { {} }

def ok(last4)
  4.times do |i|
    t = last4.split(//)
    t[i - 1], t[i] = t[i], t[i - 1] if i >= 1
    return false unless t.join.index('AGC').nil?
  end

  true
end

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

  ret = 0
  'ACGT'.each_char do |c|
    if ok(last3 + c)
      ret = (ret + dfs(cur + 1, last3[1..4] + c)) % $MOD
    end
    $memo[cur][last3] = ret
  end
  ret
end


puts dfs(0, 'TTT')