题目描述
Problem Background
Dundun invites you to share sausages equally.
Problem Description
There are $n$ sausages that need to be evenly distributed among $m$ tasters.
Each cut can divide a sausage into two parts. The goal is to use the fewest cuts to achieve the required distribution. Determine the minimum number of cuts needed.
Input Format
The input consists of a single line with two positive integers $n$ and $m$.
Output Format
Output a single line indicating the minimum number of cuts required.
Sample Input and Output
Sample Input #1
2 6
Sample Output #1
4
Sample Input #2
3 4
Sample Output #2
3
Sample Input #3
6 2
Sample Output #3
0
Notes
Sample Explanation
Sample 1 Explanation
There are 2 sausages and 6 tasters. Each sausage is divided into three parts, requiring 4 cuts in total.
Sample 2 Explanation
There are 3 sausages and 4 tasters. The sausages are cut into $\tfrac{3}{4}$. The first three tasters get $\tfrac{3}{4}$ each, and the last taster gets $3 \times \tfrac{1}{4}$.
Data Range and Constraints
For all test cases, it is guaranteed that $1 \le n, m \le 100$.
Note
This problem is translated from COCI2013-2014 CONTEST #1 T2 KUŠAČ.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分