Lights [II]


Lights [II]

The blurb for this problem is the same as Lights [I], save for the statement of the problem.

You stand before an infinitely long corridor containing lights and their respective switches. You'd like to turn a subset of the lights on using little robots that will flick certain switches infinitely along the corridor.

In this second problem, you'll be sending an infinite number of robots. The ithi^\text{th} robot will flick switches according the the following rule:

Robot ii flicks light switch jj if 2i12^{i-1} divides jj. In other words, the ithi^\text{th} robot flicks every 2i1th2^{i-1 \text{th}} switch.

A light switch stays on if after all robots are done, it has been flicked an odd number of times. For example, Light Switch #4\#4 is on because it was flicked by Robots 1, 2 and 3. While Light Switch #2\#2 is off because it was flicked by Robots 1 and 2.

Input

Input will contain a single integer nn, representing how many lights we'll be considering

Output

Output will contain a single integer, representing the total number of lights at position at or before the nthn^\text{th} light that are on at the end of execution

Constraints

  • 1n10181 \leq n \leq 10^{18}

Examples

Input 1
3
Output 1
2
Explanation

2 is the only light switch that is turned off.

Input 2
4
Output 2
3
Explanation

2 is the only light switch that is turned off.

Input 3
10
Output 3
6
Explanation

2, 6, 8, 10 are the only light switches that are turned off.

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.