Problem:
Score : 900 points

Problem Statement

Nukes has an integer that can be represented as the bitwise OR of one or more integers between A and B (inclusive).
How many possible candidates of the value of Nukes's integer there are?

Constraints

1 ≤ A ≤ B < 2^{60}

A and B are integers.

Input

The input is given from Standard Input in the following format:

A
B

Output

Print the number of possible candidates of the value of Nukes's integer.

Sample Input 1

7
9

Sample Output 1

4

In this case, A=7 and B=9. There are four integers that can be represented as the bitwise OR of a non-empty subset of {7, 8, 9}: 7, 8, 9 and 15.

Sample Input 2

65
98

Sample Output 2

63

Sample Input 3

271828182845904523
314159265358979323

Sample Output 3

68833183630578410

Solution in Rust (1.15.1) (judge verdict: Wrong Answer)

use std::io;
use std::collections::VecDeque;

fn main() {
    let mut input = Input::new();
    let mut a = input.next().parse::<i64>().unwrap();
    let mut b = input.next().parse::<i64>().unwrap();
    if a == b {
        println!(1);
        return;
    }
    let c = a ^ b;
    let t = 1i64 << (0..62).filter(|x| ((1i64 << x) & c) > 0i64).max().unwrap();
    a &= t - 1;
    b &= t - 1;
    let k = 1i64 << (0..62).filter(|x| (1i64 << x) > b).min().unwrap();
    println!("{}", t - a + t - a + if k > a { 0 } else { k });
}

struct Input {
    queue: VecDeque<String>,
}

impl Input {
    fn new() -> Input {
        Input { queue: VecDeque::new() }
    }

    fn next(&mut self) -> String {
        if self.queue.is_empty() {
            let mut line = String::new();
            let _ = io::stdin().read_line(&mut line);
            for x in line.split_whitespace() {
                self.queue.push_back(String::from(x));
            }
        }
        return self.queue.pop_front().unwrap();
    }
}