N = gets.to_i
CHARS = ['A', 'C', 'G', 'T']
dp = Array.new(N + 10)
dp[0] = { '' => 1 }

def agc_include?(str)
  [/AGC/, /ACG/, /GAC/, /A.GC/, /AG.C/].any? do |pat|
    (str =~ pat) != nil
  end
end

(1..N).each do |i|
  prev = dp[i - 1]
  CHARS.each do |ch|
    prev.each do |(prev_str, count)|
      next if agc_include?(prev_str + ch)
      if dp[i].nil?
        dp[i] = Hash.new { 0 }
      end
      last2 = (prev_str.size == 3 ? prev_str[1..-1] : prev_str)
      new_str = last2 + ch
      dp[i][new_str] += count
    end
  end
end
puts dp[N].values.reduce(&:+) % (10 ** 9 + 7)
