### COCI 2007/2008, Contest #5

Little Frane is already in tenth grade, but is still struggling with Pascal in computer class. For homework, his teacher wrote the following program into his notebook, and he needs to determine the output, given the integer N.

``````    readln(N);
counter := 0;
for i := N-1 downto 1 do begin
counter := counter + 1;
if N mod i = 0 then break;
end;
writeln(counter);
``````

Write a program which solves Frane's problem.

### Input

The first line of input contains the integer N (1 ≤ N ≤ 109).

### Output

Output the result on a single line.

`1`

`0`

`10`

`5`

`27`

### Output

`18`

Point Value: 5
Time Limit: 1.00s
Memory Limit: 32M

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

• (0/0)

• (0/0)
It’s too slow, duh! And the code provided from this question is too slow, you should understand this question before just asking why your code does not work

• (0/0)
If you don't have an understanding of Pascal, how would you do this?
I think I understand, but what about the rest?

• (1/0)
The good thing is that this reads very easily as near-direct English.

Here are equivalents in C++ and Python.
`` // C++ int N; cin >> N; int counter = 0; for (int i = N - 1; i >= 1; i--) {     counter = counter + 1;     if (N % i == 0) break; } cout << counter << '\n';  # Python N = int(input()) counter = 0 for i in range(N - 1, 0, -1):     counter = counter + 1     if N % i == 0: break print(counter) ``

• (0/0)
Can I get a Java equivalent?

• (0/0)
It's equivalent to the C++ code, except of course that it handles i/o differently.