n = gets.to_i

a, c, t, g = 0, 1, 2, 3

def is_agc(i, j, k)
  a, c, t, g = 0, 1, 2, 3
  return [i, j, k] == [a, g, c]
end

def is_ok(i, j, k, l)
  !is_agc(i, k, l) && !is_agc(j, k, l) && !is_agc(j, l, k) && !is_agc(k, j, l) && !is_agc(i, j, l)
end  


div = 1000_000_007

dp = Array.new(n+1) { Array.new(4) { Array.new(4) { Array.new(4, 0)}}}

4.times do |i|
  4.times do |j|
    4.times do |k|
        dp[3][i][j][k] = 1
    end
  end
end

dp[3][a][g][c] = 0
dp[3][a][c][g] = 0
dp[3][g][a][c] = 0

3.upto(n-1) do |epic|
  4.times do |i|
    4.times do |j|
      4.times do |k|
        sum = 0
        4.times do |l|
          sum += dp[epic][l][i][j] if is_ok(l, i, j, k)
        end

        dp[epic+1][i][j][k] = sum % div
      end
    end
  end
end

sum = 0
4.times do |i|
  4.times do |j|
    4.times do |k|
      sum += dp[n][i][j][k]
    end
  end
end

p sum % div
