eolymp
bolt
Try our new interface for solving problems
Problems

Mathematical game

Mathematical game

Consider a mathematical game, two players MDM dylayut moves in turn. Given natural number \textbf{N}. In one move, this number must be reduced by the value of some natural number which does not exceed the value of \textbf{M} so that the result remained non-negative. Losing someone who could not make a move. And the value of \textbf{M} selects a player who goes second. For a given \textbf{N} to find the smallest possible value of \textbf{M}, which gives the second player a real chance to win, or output \textbf{0} in a losing case. \InputFile One number \textbf{N} (\textbf{N} < \textbf{10^5}). \OutputFile One number \textbf{M} - solution to the problem.
Time limit 1 second
Memory limit 64 MiB
Input example #1
7
Output example #1
6