N = gets.to_i
MOD = 10 ** 9 + 7
dp = Array.new(N + 1) { Hash.new { 0 } }
dp[0][''] = 1

def included_agc(ss, ch)
  return false if ss.size <= 1
  return true if (ss[-2..-1] + [ch]).join('') == 'AGC'
  new_ss = ss + [ch]
  (0..(new_ss.size - 2)).any? do |i|
    ts = new_ss.dup
    t = ts[i + 1]
    ts[i + 1] = ts[i]
    ts[i] = t
    ns = (ts + [ch]).join('')
    ns.include?('AGC')
  end
end

N.times do |i|
  dp[i].keys.each do |s|
    ss = s.chars
    %w[A C G T].each do |ch|
      unless included_agc(ss, ch)
        new_s = if ss.size <= 1
          s + ch
        else
          (ss[-2..-1] + [ch]).join('')
        end
        dp[i + 1][new_s] += dp[i][s] % MOD
      end
    end
  end
end
ans = dp[N].values.reduce(0) do |acc, n|
  (acc + n) % MOD
end
puts ans
