a, c = io.read("*n", "*n") t = {} while(a ~= 0 or c ~= 0) do if(a % 2 == c % 2) then table.insert(t, 0) else table.insert(t, 1) end a, c = math.floor(a / 2), math.floor(c / 2) end ret = 0 for k, v in pairs(t) do ret = ret + v * math.pow(2, k - 1) end print(ret)