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

#SP0000023. Orac và phép cộng ước nhỏ nhất (Orac and Factors)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Orac và phép cộng ước nhỏ nhất (Orac and Factors)

Orac and Factors

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

For any integer v≥2v\ge2, let f(v)f(v) denote its smallest positive divisor greater than 11. For example, f(7)=7f(7)=7, f(10)=2f(10)=2, and f(35)=5f(35)=5. Start with integer nn and perform exactly kk operations, each replacing the current value vv by v+f(v)v+f(v). The divisor is recomputed from the current value after each update. Print the final value.

Input

One line contains integers nn and kk, in that order.

Output

Print one integer: the value after exactly kk operations.

Subtasks

  • Subtask 1 (20 points): 2≤n≤1002\le n\le 100, 1≤k≤201\le k\le 20.
  • Subtask 2 (30 points): 2≤n≤100002\le n\le 10000, 1≤k≤1000001\le k\le 100000.
  • Subtask 3 (50 points): 2≤n≤10000002\le n\le 1000000, 1≤k≤10000000001\le k\le 1000000000.

Examples

Input

5 1

Output

10

Explanation

Since 55 is prime, f(5)=5f(5)=5. The single operation produces 5+5=105+5=10, so print 10.

Input

8 2

Output

12

Explanation

At step 11, f(8)=2f(8)=2 gives 8→108\to10. At step 22, recompute f(10)=2f(10)=2 and obtain 10→1210\to12. Print 12.

Input

3 4

Output

12

Explanation

Starting from 33, the four successive values are 3→6→8→10→123\to6\to8\to10\to12, since f(3)=3f(3)=3 and all later numbers are even with smallest divisor 22.