// use std::ops::{Index, IndexMut};
// use std::cmp::{Ordering, min, max};
// use std::collections::{BinaryHeap, BTreeMap};
// use std::collections::btree_map::Entry::{Occupied, Vacant};
// use std::clone::Clone;

fn getline() -> String{
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) 
        }
    };
}

macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

macro_rules! mvec {
    ($v: expr, $s: expr) => {
        vec![$v; $s]
    };
    ($v: expr, $s: expr, $($t: expr),*) => {
        vec![mvec!($v, $($t),*); $s]
    };
}

macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator, 
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display {
    for (i,e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}

fn naive(a: usize, b: usize) -> u64 {
    println!("{:b}", a);
    println!("{:b}", b);
    let up = |mut x: usize|  {
        let mut res = 0;
        while x != 0 {
            res += 1;
            x >>= 1;
        }
        res
    };
    let mut dp = vec![false; 1<<up(b)];
    dp[a] = true;
    // debug!(dp);
    for num in a+1..b+1 {
        // debug!(num);
        let mut nex = dp.clone();
        nex[num] = true;
        for mask in 0..dp.len() {
            nex[mask|num] = nex[mask|num]||dp[mask];
        }
        dp = nex;
    }
    let a = dp.iter().fold(0, |sum, &x| {
        if x {
            sum + 1
        } else {
            sum
        }
    });
    // debug!(dp);
    a
}

fn solve(mut a: usize, mut b: usize) -> u64 {
    const MAX: usize = 61;
    for i in (0..MAX).rev() {
        if ((a>>i)&1) == ((b>>i)&1) {
            a = (!(1<<i))&a;
            b = (!(1<<i))&b;
        } else {
            break;
        }
    }
    if a == b {
        return 1;
    }
    let blen = {
        let mut b = b;
        let mut cnt = 0;
        while b != 0 {
            cnt += 1;
            b >>= 1;
        }
        cnt-1
    };
    // debug!(a); debug!(b);
    let mut res = ((1<<blen)-a)*2;
    // debug!((1<<blen)-a);
    let to = {
        let mut s = false;
        let mut res = None;
        for i in (0..MAX).rev() {
            if (b>>i)&1 == 1 {
                // debug!(i);
                if !s {
                    s = true;
                } else {
                    res = Some(i);
                    break;
                }
            }
        }
        res
    };
    // debug!(to);
    if let Some(to) = to {
        let add = (1<<to+1);
        // debug!(add);
        res += add;
        if add >= a {
            res -= add-a;
        }
    } else if a != 0 {
        res += 1;
    }
    // res += 1;
    res as u64
}

fn main() {
    let a = readl!(usize);
    let b = readl!(usize);
    // println!("{}", naive(a, b));
    println!("{}", solve(a, b));
}



Measured memory_bytes: 4352