local N = io.read("n")

local MOD = 1000000007
local chars = {'A', 'C', 'G', 'T'}
local tbl = {}

function tbl.lookup(n, c1, c2, c3)
    local val = tbl[tostring(n) .. c1 .. c2 .. c3]
    if not val then
        val = 0
        tbl[tostring(n) .. c1 .. c2 .. c3] = val
    end
    return val
end

function tbl.update(n, c1, c2, c3, val)
    tbl[tostring(n) .. c1 .. c2 .. c3] = val
end

tbl.update(0,'T','T','T',1)

for i=1,N do
    for k=0,63 do
        local c1 = chars[(k & 3) + 1]
        local c2 = chars[((k >> 2) & 3) + 1]
        local c3 = chars[((k >> 4) & 3) + 1]
        if tbl.lookup(i-1, c1, c2, c3) ~= 0 then
            for _,a in pairs(chars) do
                local ng_cond = a .. c1 .. c2 == 'AGC'
                            or a .. c1 .. c2 == 'ACG'
                            or a .. c1 .. c2 == 'GAC'
                            or a .. c2 .. c3 == 'AGC'
                            or a .. c1 .. c3 == 'AGC'
                if not ng_cond then
                    local old = tbl.lookup(i, a, c1, c2)
                    local origin = tbl.lookup(i-1, c1, c2, c3)
                    tbl.update(i, a, c1, c2, (old + origin) % MOD)
                end
            end
        end
    end
end

local ans = 0
for k=0,63 do
    local c1 = chars[(k & 3) + 1]
    local c2 = chars[((k >> 2) & 3) + 1]
    local c3 = chars[((k >> 4) & 3) + 1]
    ans = (ans + tbl.lookup(N, c1, c2, c3)) % MOD
end

print(ans)
