프로그램 명: coci_reseto
제한시간: 1 초

[문제요약] N 까지의 소수를 구할 때 이용하는 알고리즘 에라토스테네스의 체를 알고 있죠? 문제는 N 과 K 가 주어질 때 K 번째로 걸러지는(지워지는) 수를 구하는 것이 문제이다.


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.

입력

The integers N and K (2 ≤ K < N ≤ 1000).

출력

Output the K-th number to be crossed out.

입출력 예

input 

7 3 

output 

6 

input 

15 7 

output 

12

input 

10 7 

output 

9 

EXAMPLES

In the third example, we cross out, in order, the numbers 2, 4, 6, 8, 10, 3, 9, 5 and 7. The seventh number is 9.
출처: coci 2008/2009 2/6

[질/답] [제출 현황] [푼 후(0)]
[ 채 점 ] [홈으로]  [뒤 로]