405097: GYM101790 G Task distributor

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

G. Task distributortime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Every second the task distributor receives a new task. Tasks are numbered sequentially, starting from zero.

If the task number is not divided into K, then its execution on any server takes T seconds, otherwise it takes 2 × T seconds.

After receiving the task, the distributor immediately transfers it to one of the free servers. If there are no free servers at the time of the task's receipt, then a collapse occurs.

Initially, all servers are free. The server executing the task becomes free immediately when the task execution is finished.

What is the minimum number of servers needed to ensure that the collapse never occurs?

Input

The first and only line contains two integers T (1 ≤ T ≤ 1018) and K (1 ≤ K ≤ 1018).

Output

Display the minimum number of servers needed to ensure that the collapse never occurs.

ExamplesInput
4 3
Output
6
Input
3 4
Output
4
Input
2 2
Output
3
Input
1 2
Output
2

加入题单

算法标签: