#acl1b. [acl1_b]Sum is Multiple

[acl1_b]Sum is Multiple

Problem Statement

Given is an integer NN. Find the minimum possible positive integer kk such that (1+2+cdots+k)(1+2+\\cdots+k) is a multiple of NN. It can be proved that such a positive integer kk always exists.

Constraints

  • 1leqNleq10151 \\leq N \\leq 10^{15}
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

Output

Print the answer in a line.


Sample Input 1

11

Sample Output 1

10

1+2+cdots+10=551+2+\\cdots+10=55 holds and 5555 is indeed a multple of N=11N=11. There are no positive integers kleq9k \\leq 9 that satisfy the condition, so the answer is k=10k = 10.


Sample Input 2

20200920

Sample Output 2

1100144