require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i

dp = [n-2]
dp[0] = {}
agct = ["A", "G", "C", "T"]
agct.each do |a|
  agct.each do |b|
    agct.each do |c|
      dp[0][a+b+c] = 1
    end
  end
end
dp[0]["AGC"] = 0
dp[0]["GAC"] = 0
dp[0]["ACG"] = 0

def agc?(s)
  s =~ /(AGC.)|(GAC.)|(ACG.)|(.AGC)|(.ACG)|(.GAC)|(A.GC)|(AG.C)/
end

1.upto(n-3).each do |i|
  dp[i] = {}
  dp[i].default = 0

  dp[i-1].each do |k, v|
    agct.each do |add|
      if !agc?(k + add)
        key = k.slice(1,2) + add
        dp[i][key] += v
        dp[i][key] %= MOD #=
      end
    end
  end
end

# p dp[n-3]
p dp[n-3].values.inject(&:+) % MOD

