Yeongseon sequence

Count integers X in [A, B] whose Yeongseon sequence (halve evens, subtract 1 from odds) eventually hits K.

Medium7MathBit manipulationBinary searchCombinatoricsNo attempts yetTime limit2sMemory limit512 MB

Problem

For a non-negative integer XX, the Yeongseon sequence of XX is the infinite sequence defined as follows.

  • The first number is XX.
  • The number that follows an even number YY is Y/2Y/2. (00 is even.)
  • The number that follows an odd number ZZ is Z1Z-1.

For example, the Yeongseon sequence of 6060 is 60,30,15,14,7,6,60, 30, 15, 14, 7, 6, \dots.

Given KK, AA, and BB, write a program that counts the integers XX with AXBA \le X \le B whose Yeongseon sequence contains KK.

Input

The first line contains KK, AA, and BB, separated by spaces. (0K10180 \le K \le 10^{18}, 0AB10180 \le A \le B \le 10^{18})

Output

Print on the first line the number of integers XX that satisfy the condition.