local mfl, mce = math.floor, math.ceil
local mab = math.abs
local n = io.read("*n", "*l")
local s = io.read()
local t = {}
for i = 1, n - 1 do
  t[i] = mab(s:sub(i + 1, i + 1):byte() - s:sub(i, i):byte())
end
local hasone = false
for i = 1, n - 1 do
  if t[i] == 1 then hasone = true break end
end
if hasone then
  for i = 1, n - 1 do
    t[i] = t[i] % 2
  end
else
  for i = 1, n - 1 do
    t[i] = t[i] / 2
  end
end

n = n - 1

-- odd: True
local function solve(depth, left)
  local mul, stage = 2, 1
  while true do
    if depth <= mul then break end
    stage = stage + 1
    mul = mul * 2
  end
  -- print("SOLVE", depth, left, stage, mul)
  if stage == 1 then
    return true
  else
    local depth_ofst = depth - (mul / 2)
    if left <= depth_ofst then
      return solve(depth_ofst, left)
    else
      if (mul / 2) < left then
        return solve(depth_ofst, left - (mul / 2))
      else
        return false
      end
    end
  end
end
local ret = 0
for i = 1, n do
  local f = solve(n, i)
    -- print("SOLVE", i, f)
  if f then -- Odd
    if t[i] % 2 == 1 then
      ret = (ret + 1) % 2
    end
  end
end
if not hasone then ret = ret * 2 end
print(ret)
