401370: GYM100418 J Lucky tickets

Memory Limit:64 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. Lucky ticketstime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard output

Everyone knows that in less than a month the Ice Hockey World Championship will start in Minsk. But few of the guests of our city know that this is the reason why the new tickets and system of accounting were introduced in the public transport (which at the moment is unstable due to some structural flaws). It is obvious that the new tickets require the new formula for determining whether they are lucky or not. It is such an important task that it was given to the authors of BSUIR Open problems. After months of deliberation and disputes the following formula was proposed: a ticket is lucky if it is divisible by the number of symbol 1 in the binary representation. And then the authors thought that the number of these lucky tickets would be too big. Therefore, they asked you for help. Determine the quantity of lucky tickets with numbers from the interval [1..N].

Input

The first line contains the integer number N (1 ≤ N ≤ 1019).

Output

Output the number of lucky tickets.

ExamplesInput
153
Output
42

加入题单

算法标签: