Under construction

Still being built. Things may change

Counting Ones in a Range

Interview

Time limit1sMemory limit128 MB

Summary
Add up the number of 1 bits in the binary form of every integer from A to B.
Level

Medium5 of 10

Topics
Bit manipulation, Math
Solved
No attempts yet

Problem

You are given two natural numbers AA and BB. Write every integer xx with A≤x≤BA \le x \le B in binary, count the 1 digits in each one, and add all of those counts together.

Let f(x)f(x) be the number of 1 digits in the binary representation of xx. Compute the value below.

∑x=ABf(x)\sum_{x=A}^{B} f(x)

Input

The first line contains two natural numbers AA and BB, separated by a space. (1≤A≤B≤10161 \le A \le B \le 10^{16})

Output

Print the sum of the 1 counts on the first line.

Examples1

  1. Example 1

    Input
    2 12
    
    Expected output
    21