Page not loading? Try clicking here.
Placeholder

#1402

Divisor 1s 32MB

Problems

For natural numbers p and q, if the remainder of p divided by q is 0, then q is a divisor of p.

For example, for 6:

  • 6 \div 1 = 6 \dots 0

  • 6 \div 2 = 3 \dots 0

  • 6 \div 3 = 2 \dots 0

  • 6 \div 4 = 1 \dots 2

  • 6 \div 5 = 1 \dots 1

  • 6 \div 6 = 1 \dots 0

Thus, the divisors of 6 are 1, 2, 3, and 6 — a total of four divisors.

Given two natural numbers N and K, write a program to output the K-th smallest divisor of N.


Input

The first line contains N and K, separated by a space.

  • 1 \le N \le 10{,}000

  • 1 \le K \le N


Output

Print the K-th smallest divisor of N.

If N has fewer than K divisors (so the K-th divisor does not exist), output 0.


Example #1

6 3
3

Example #2

25 4
0

Example #3

2735 1
1


Source

KOI 본선 2008 초1

You must sign in to write code.