local DBG = false
function dbgpr(...)
    if DBG then
        io.write("[dbg]")
        print(...)
    end
end

function dbgpr_t(tbl)
    if DBG then
        dbgpr(tbl)
        io.write("[dbg]")
        for i,v in ipairs(tbl) do
            io.write(i)
            io.write(":")
            io.write(tostring(v))
            io.write(" ")
        end
        print("")
    end
end


local A, B = io.read("n", "n")
local function bit0()
    local a, b = A & 1, B & 1
    local b_minus_a = B - A
    local mod4 = b_minus_a % 4
    dbgpr(A,B,a,b,b_minus_a,mod4)
    if a == 0 then
        local t = {0,1,1,0}
        return t[mod4 + 1]
    else
        local t = {1,1,0,0}
        return t[mod4 + 1]
    end
end
local bits = {}
bits[1] = bit0()
dbgpr("bit0:", bits[1])
--if true then return end
-- 10**12 => 40bits
for iplus1=2, 40 do
    local i = iplus1 - 1
    local bitpos = 1 << i
    local a_posi, b_posi = A & bitpos, B & bitpos
    local a_mod, b_mod = A & (bitpos - 1), B & (bitpos - 1)
    local a_ones, b_ones
    if a_posi ~= 0 then
        a_ones = a_posi - a_mod
    else
        a_ones = 0
    end
    if b_posi ~= 0 then
        b_ones = b_mod + 1
    else
        b_ones = 0
    end
    local c
    if ((a_ones + b_ones) & 1) ~= 0 then
        c = 1
    else
        c = 0
    end
    dbgpr(i, a_ones, b_ones, (a_ones + b_ones) & 1, c)
    bits[iplus1] = c
end
dbgpr(#bits)
local ans_r = table.concat(bits)
local ans = string.reverse(ans_r)
dbgpr("ans in bin:",ans)
local Adec = 0
for i=0,39 do
    Adec = Adec + (bits[i+1] << i)
end
print(Adec)