#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def each_cons_with_ends(num)
    array = []
    each_cons(num).with_index do |*x, i|
      prev = i > 0 ? self[0..i-1] : []
      following = self[(i+num)..]
      yield(*x, prev, following) if block_given?
      array << [*x, prev, following]
    end
    array.to_enum
  end

  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

def exponential_with_mod(n, k, mod)
  return 1 if k == 0
  return n if k == 1

  if k % 2 == 1
    (n * (exponential_with_mod(n, k/2, mod) ** 2 % mod)) % mod
  else
    (exponential_with_mod(n, k/2, mod) ** 2) % mod
  end
end

# mod m での aの逆元
# mが素数のときのみ有効
def modinv(a, m)
  b = m; u = 1; v = 0

  while b != 0
    t = a / b
    a -= t * b
    c = a; a = b; b = c
    u -= t * v
    c = u; u = v; v = c
  end
  u %= m
  u += m if u < 0
  u
end

def nCk(n, k, mod)
  ue = 1
  shita = 1
  k.times do |a|
    ue = ue * (n - a) % mod
    shita = shita * (k - a) % mod
  end
  ue * modinv(shita, mod) % mod
end

N = get_int

MOD = 10 ** 9 + 7

@memo = Array.new(N+1) { {} }

def ok(last4)
  4.times do |i|
    return false if last4.include?('ACG')
    chars = last4.split('')
    return false if chars.each_cons_with_ends(2).any? do |(a, b), prev, fol|
      (prev + [b, a] + fol).join.include?('ACG')
    end
  end
  return true
end

def dfs(cur, last3)
  return @memo[cur][last3] if @memo[cur][last3]
  return 1 if cur == N

  ret = 0
  %w[A C G T].each do |s|
    ret = (ret + dfs(cur+1, last3[1..] + s)) % MOD if ok(last3 + s)
  end
  @memo[cur][last3] = ret
  ret
end

puts dfs(0, 'TTT')
