Lights Out!
Input: Standard Input (stdin)
Output: Standard Output (stdout)
Memory limit: 128 megabytes
Time limit: 1.0 seconds
Output: Standard Output (stdout)
Memory limit: 128 megabytes
Time limit: 1.0 seconds
There are number of lights along a corridor. All of the lights are off. Each light has an on-off
switch.
Several people walk along the corridor, one after another.
- The first flips every switch, turning them all on.
- The second flips every second switch, starting from the second, turning about half of them off.
- The third flips every third switch, starting from the third, turning some on and some off.
- The fourth flips every fourth switch, starting from the fourth.
- etc.
After all of the people have walked the corridor, how many switches are on?
Input
The input will be a two lines.
The first line contains N, the number of lights in the corridor.
The second line contains M, the number of people.
Output
Ouput the number of lights on after the M people have walked along the corridor.
Constraints
- 1 \le M \le N
- 1 \le N \le 1,000
Subtasks
- Subtask 1 (+30%): M = 1.
- Subtask 2 (+30%): M \le 2.
- Subtask 3 (+40%): No further constraints apply.
-
Sample Input 1
4 2
Sample Output 1
2
-
Sample Input 2
17 1
Sample Output 2
17
-
Sample Input 3
17 13
Sample Output 3
6