N = gets.to_i
MOD = 10 ** 9 + 7

s = ["A", "C", "G", "T"]
ex = ["AGC", "ACG", "GAC"]
c = Hash.new{|h, k| h[k] = 0}
["A", "C", "G", "T"].repeated_permutation(3).each{|a|
  c[a.join] = 1
}
ex.each{|a| c[a] = 0}

wk = 3
while wk < N do
  nxt = Hash.new{|h, k| h[k] = 0}
  c.each{|k, v|
    s.each{|t|
      next if /A.GC|AG.C/ =~ k+t
      nxt[k[1,2] + t] += v
    }
  }
  c = nxt.map{|k, v| [k, ex.include?(k) ? 0 : v % MOD]}
  wk += 1
end

puts c.inject(0){|r, (k, v)| r + v} % MOD
