local function memoize(f)
    local cache = {}
    local function key(...)
        local args = {...}
        local k = tostring(args[1])
        for i=2,#args do
            k = k .. "*" .. tostring(args[i])
        end
        return k
    end
    return function(...)
        local k = key(...)
        if cache[k] then
            return cache[k]
        end
        local r = f(...)
        cache[k] = r
        return r
    end
end

local N = io.read("n")

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

local function gen_charset()
    return coroutine.wrap(function()
        for _,c1 in ipairs(chars) do
            for _,c2 in ipairs(chars) do
                for _,c3 in ipairs(chars) do
                    coroutine.yield({c1,c2,c3})
                end
            end
        end
    end)
end

local count
count = memoize(function(n, c1, c2, c3)
    local c1c2c3 = c1 .. c2 .. c3
    if n == 0 then
        if c1c2c3 == 'TTT' then
            return 1
        else
            return 0
        end
    end
    for _,ng in pairs{'AGC', 'ACG', 'GAC'} do
        if c1c2c3 == ng then
            return 0
        end
    end
    local ans = 0
    for _, c4 in ipairs(chars) do
        local ng_cond = c1 .. c3 .. c4 == 'AGC'
                        or c1 .. c2 .. c4 == 'AGC'
        if not ng_cond then
            ans = (ans + count(n-1,c2,c3,c4)) % MOD
        end
    end
    return ans
end)

local ans = 0
for t in gen_charset() do
    ans = (ans + count(N, t[1], t[2], t[3])) % MOD
end

print(ans)
