100 atcoder#ABC144C. [ABC144C] Walk on Multiplication Table
[ABC144C] Walk on Multiplication Table
Score : points
Problem Statement
Takahashi is standing on a multiplication table with infinitely many rows and columns.
The square contains the integer . Initially, Takahashi is standing at .
In one move, he can move from to either or .
Given an integer , find the minimum number of moves needed to reach a square that contains .
Constraints
- is an integer.
Input
Input is given from Standard Input in the following format:
Output
Print the minimum number of moves needed to reach a square that contains the integer .
10
5
can be reached in five moves. We cannot reach a square that contains in less than five moves.
50
13
can be reached in moves.
10000000019
10000000018
Both input and output may be enormous.