Pocetna test 2 - UMKS zimski kamp 2019

Start

2019-01-13 12:15 UTC

Pocetna test 2 - UMKS zimski kamp 2019

End

2019-01-13 15:00 UTC
The end is near!
Contest is over.
Not yet started.
Contest is starting in -190 days 17:32:34

Time elapsed

2:45:00

Time remaining

0:00:00

Problem D
Reseto

The sieve of Eratosthenes is a famous algorithm to find all prime numbers up to $N$. The algorithm is:

  1. Write down all integers between 2 and $N$, inclusive.

  2. Find the smallest number not already crossed out and call it $P$; $P$ is prime.

  3. Cross out $P$ and all its multiples that aren’t already crossed out.

  4. If not all numbers have been crossed out, go to step 2.

Write a program that, given $N$ and $K$, find the $K$-th integer to be crossed out.

Input

The integers $N$ and $K$ $(1 \leq K < N \leq 100\, 000)$.

Output

Output the $K$-th number to be crossed out.

Sample Input 1 Sample Output 1
7 3
6
Sample Input 2 Sample Output 2
15 12
7
Sample Input 3 Sample Output 3
10 7
9