N = gets.to_i

MOD = 1000000007


res = {}

['a','c','g','t'].repeated_permutation(3).each do |a,b,c|
  k = a + b + c
  if ['agc' , 'acg' , 'gac'].include? k
    res[k] = 0
  else
    res[k] = 1
  end
end

(4..N).each do |_|
  n_res = Hash.new(0)
  ['a','c','g','t'].repeated_permutation(3).each do |a,b,c|
    k = a + b + c
    ['a','c','g','t'].each do |s|
      unless a + b + s == 'agc'
        unless a + c + s == 'agc'
          n_k = b + c + s
          unless ['agc', 'acg', 'gac'].include? n_k
            n_res[n_k] = (res[k] + n_res[n_k])%MOD
          end
        end
      end
    end
  end
  res = n_res
end

puts (res.reduce(0) do |re, (k,v)|
  re = (v + re)%MOD
end)
