D - A or...or B Problem 解説 /

実行時間制限: 2 sec / メモリ制限: 256 MB

配点 : 900

問題文

ぬけす君は、A 以上 B 以下の整数から 1 個以上選んで、それらの整数の bitwise or を取ってできる整数を持っています。 ぬけす君が持っている整数としてありうるものは何通りあるでしょうか。

制約

  • 1 ≦ A ≦ B < 2^{60}
  • A,B は整数である

入力

入力は以下の形式で標準入力から与えられる。

A
B

出力

ぬけす君が持っている整数としてありうるものの個数を出力せよ。


入力例 1

7
9

出力例 1

4

7,8,9 のうちの 1 個以上の整数の bitwise or で書ける整数は、7,8,9,154 つです。


入力例 2

65
98

出力例 2

63

入力例 3

271828182845904523
314159265358979323

出力例 3

68833183630578410

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