Just in Time

Given N rooms where each room has one random outgoing tunnel, choose T in [2, N] maximizing the chance a walker starting in room 1 is not back in room 1 at time T.

Medium7ProbabilityMathCombinatoricsNumber theoryNo attempts yetTime limit2sMemory limit512 MB

Problem

Hello, contestant. Let us play a game. Your coach is standing in the contest room, holding a bomb that will detonate in TT seconds. If it goes off inside the contest room, it destroys your team's balloons and nobody else's.

The building that holds the contest room has NN rooms in total. Out of each room runs exactly one tunnel to a different room, and that tunnel can be used in one direction only. If room AA leads to room BB, you can walk from AA to BB, but you cannot walk from BB to AA unless room BB has a tunnel of its own to room AA.

The bomb senses the moment your coach stops moving and detonates right then. So your coach keeps walking from room to room, and passing through one tunnel takes exactly one second. He starts in the contest room, and because each room has a single outgoing tunnel, his route is fixed by the layout of the building. The only way to save the balloons is for your coach to be somewhere other than the contest room when the bomb detonates.

You do not get the map. All I will tell you is that the tunnels were chosen uniformly at random. In exchange, you get to set TT, which must be an integer between 22 and NN inclusive. Choose TT so that the chance your balloons survive is as large as possible.

Exactly one value of TT reaches that maximum.

Let the game begin.

Input

The first line contains one integer NN, the number of rooms in the building (2N1092 \le N \le 10^9).

Output

Print, on one line, the value of TT that maximizes the probability that your balloons survive.