# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

nn = inputs[0][0]

# body
if $debugFlag
end

def isOK3(str)
  return (str != 'AGC' and str != 'ACG' and str != 'GAC')
end

def isOK4(str)
  cond = true
  3.times do |i|
    tmp = str.clone
    tmp[i], tmp[i+1] = tmp[i+1], tmp[i]
    cond = false if (tmp[0..2] == 'AGC' or tmp[1..3] == 'AGC')
  end
  cond = false if (str[0..2] == 'AGC' or str[1..3] == 'AGC')  

  return cond
end

last3 = {}
cand = ['A', 'C', 'T', 'G']
cand.each do |i|
  cand.each do |j|
    cand.each do |k|
      if isOK3 (i + j + k)
        if last3[i+j+k] != nil
          last3[i+j+k] += 1
        else
          last3[i+j+k] = 1
        end
      end
    end
  end
end

pd last3
if $debugFlag
  cnt = 0
  last3.each do |k,v|
    cnt += v
  end
  p cnt
end

for i in 4..nn do
  i = i
  prev_last3 = last3.clone
  last3 = {}
  cand.each do |c|
    prev_last3.each do |k, v|
      if isOK4(k + c)
        #pd k+c
        if last3[k[1..2] + c] != nil
          last3[k[1..2] + c] += v
        else
          last3[k[1..2] + c] = v
        end
      else
        #puts k + c
      end
    end
  end
  ans = last3.clone
end

cnt = 0
ans.each do |k,v|
  cnt += v
end

puts cnt%(10**9+7)

