PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000196. Tìm số theo tổng các ước (Short Task)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tìm số theo tổng các ước (Short Task)

Tìm số theo tổng các ước (Short Task)

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Let σ(x)\sigma(x) denote the sum of all positive divisors of xx. Given cc, find the smallest positive integer xx with σ(x)=c\sigma(x)=c, or -1 if no such integer exists.

Input

One integer cc.

Output

Print the minimum xx, or -1.

Subtasks

  • Subtask 1 (20 points): 1≤c≤100001\le c\le 10000.

  • Subtask 2 (30 points): 1≤c≤10000001\le c\le 1000000.

  • Subtask 3 (50 points): 1≤c≤100000001\le c\le 10000000.

Examples

Example 1

Input

1

Output

1

Explanation

The only positive divisor of 11 is itself, so its divisor sum is 11.

Example 2

Input

12

Output

6

Explanation

The positive divisors of 66 are 1,2,3,61,2,3,6, summing to 1212. No smaller positive integer has divisor sum 1212.

Example 3

Input

2

Output

-1

Explanation

The sum is 11 for x=1x=1, and at least 1+x≥31+x\ge3 for x>1x>1; thus 22 is unattainable.