program a_or_or_or_b_problem
  implicit none
  integer(8) :: a, b, d1, u1, d2, u2, ans
  integer :: i, r, k
  read(*,*) a
  read(*,*) b
  if (a == b) then
    write(*,'(i0)') 1
    stop
  end if
  do i = 61, 1, -1
    if (btest(a,i-1) .eqv. btest(b,i-1)) then
      a = ibclr(a,i-1)
      b = ibclr(b,i-1)
    else
      r = i
      exit
    end if
  end do
  k = 0
  do i = r-1, 1, -1
    if (btest(b,i-1)) then
      k = i
      exit
    end if
  end do
  d1 = a
  u1 = lshift(1_8,r-1)+lshift(1_8,k)
  d2 = lshift(1_8,r-1)+a
  u2 = lshift(1_8,r)
  if (d2 <= u1) then
    ans = u2-d1
  else
    ans = u1-d1+u2-d2
  end if
  write(*,'(i0)') ans
end program a_or_or_or_b_problem