Since the CCO often uses integers, Alice needs to learn about the integers! A positive integer can be written in base as the sequence if the following hold:
Each digit is between 0 and , inclusive.
.
.
For example, the integer 2025 in base 19 is the sequence because .
An integer is -balanced if, when is written in base , the average of the digits is . For example, 2025 is 19-balanced because .
Alice can easily find integers that are 19-balanced. However, she has trouble finding integers that are balanced in multiple ways. Given and , please help Alice find the minimum integer such that:
is -balanced, for all .
.
输入格式
The first line of input contains two space-separated integers and ().
It is guaranteed that the answer does not exceed .
输出格式
Output the minimum integer from the problem statement.
样例
样例输入 1
4 100
样例输出 1
141
样例输入 2
7 10000000000
样例输出 2
16926961207710
数据范围与提示
Sample 1 Explanation
in base is . The average digit is
Therefore, is 2-balanced.
in base 3 is . The average digit is
Therefore, is 3-balanced.
in base 4 is . The average digit is
Therefore, is 4-balanced.
Lastly, .
Feel free to use these code snippets as part of your solution.
// Important: If x is 0, the result is undefined.
intbase_2_length(unsignedlonglongx){return64-__builtin_clzll(x);}intbase_2_sum(unsignedlonglongx){return__builtin_popcountll(x);}
The following table shows how the available marks are distributed: