Shuffled Deck

For a deck of P distinct cards, find how many times the given interleaving shuffle must be repeated until the deck returns to its sorted order.

Medium5MathSortingNumber theoryNo attempts yetTime limit2sMemory limit512 MB

Problem

A deck holds an even number 2n2n of cards a1,a2,,a2na_1, a_2, \dots, a_{2n}, all distinct (a1<a2<<a2na_1 < a_2 < \dots < a_{2n}). At the start the deck is perfectly sorted: the first card is a1a_1, the second card is a2a_2, and so on until the last card, which is a2na_{2n}.

A dealer then repeats a shuffle made of two steps.

  1. Split the deck into two halves.
  2. Interleave the cards of the two halves. If the card order at the start of step 1 is x1,x2,,x2nx_1, x_2, \dots, x_{2n}, then after step 2 the order becomes xn+1,x1,xn+2,x2,,x2n,xnx_{n+1}, x_1, x_{n+2}, x_2, \dots, x_{2n}, x_n.

Given the number of cards in the deck, write a program that determines how many times this shuffle must be repeated for the deck to return to its original sorted order.

Input

The first line contains an even integer PP, the number of cards in the deck (2P2×1052 \le P \le 2 \times 10^5). The value PP corresponds to 2n2n in the description above.

Output

Print one line with a single integer, the minimum number of times the shuffle must be repeated for the deck to be sorted again.