All problems

Problem 358

Bulb Switcher

Medium · 20 pts · Math, Brainteaser

Problem

There are N bulbs in a row, all initially off. In round 1 you switch every bulb on. In round 2 you toggle every 2nd bulb, in round 3 every 3rd bulb, and in round i you toggle every i-th bulb, for N rounds in total. How many bulbs are on at the end? Bulb k is toggled once for every divisor of k, so it ends up on exactly when k has an odd number of divisors, which happens only for perfect squares. The numbers in this problem can be larger than a 32-bit int can hold (about 2.1 × 10^9), so use a 64-bit integer type: long long in C++, long in Java (Python needs nothing special).

Input

A single integer N.

Output

Print the number of bulbs that are on after N rounds.

Constraints

0 <= N <= 10^18

Example input

3

Example output

1

Explanation

With 3 bulbs: after round 1 they are on, on, on; after round 2 on, off, on; after round 3 on, off, off. One bulb stays on.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Integer Break Next: Nth Digit of the Integer Sequence