#P9226. 糖果

糖果

Problem Description

There are nn students in Class 7 of Grade 3. When PE class begins, they stand in a line from left to right, preparing to count off and form groups.

The PE teacher has many bags of candy in his pocket (each bag contains many candies). He plans to hand out these bags of candy to the students while forming groups.

Specifically, during the counting process from left to right, every time kk students are counted, the PE teacher forms these kk students into a group, and gives one bag of candy to the last student among these kk students, who will be responsible for distributing it to the students in the group. In other words, the PE teacher will give a bag of candy to the k,2k,k, 2k, \cdots-th students from left to right.

By coincidence, the students of Class 6 of Grade 3 heard the news that Class 7 of Grade 3 is giving out candy, so they plan to blend into the end of the line (the far right of the line), trying to get a bag of candy for free.

The students of Class 6 of Grade 3 want to know how many students they need to add to the end of the line at least.

Input Format

One line with two integers n,kn, k.

Output Format

One line with one integer, representing the answer.

10 3
2
16 4
4

Hint

Explanation for Sample 1

Here, students are grouped every 33 people. Class 6 of Grade 3 only needs to add 22 students into the line, so they can form a group together with the last 11 student of the original Class 7 of Grade 3.

Since these 22 added students are at the end of the line, the last student in this group must be a student from the neighboring class, so the neighboring class can get a bag of candy for free.

Explanation for Sample 2

Here, students are grouped every 44 people. All students in Class 7 of Grade 3 have already been grouped, so Class 6 of Grade 3 needs to add a full 44 students into the line to form a group, in order to get a bag of candy for free.

Constraints

For 100%100\% of the testdata, 1n1091 \leq n \leq 10 ^ {9}, 2k1092 \leq k \leq 10 ^ 9.

Test Point ID nn kk
121 \sim 2 10\leq 10 =2= 2
353 \sim 5 10\leq 10
6106 \sim 10 1000\leq 1000
111411 \sim 14 109\leq 10 ^ 9 =2= 2
152015 \sim 20 109\leq 10 ^ 9

Translated by ChatGPT 5