#P6101. [EER2] 出言不逊
[EER2] 出言不逊
Description
Keai wants to participate in an open contest, but she gets rejected every time.
Keai is very angry, so she learned to speak rudely.
Keai uses a string to store what she wants to say, but this sentence is too mild. To speak rudely, Keai needs to operate on the string. In each operation, Keai can choose a character . If appears times in string , then Keai will append copies of character to the end of .
Keai thinks that only when the length of this string is at least can she speak rudely. Keai wants to know the minimum number of operations needed to make the length of this string greater than or equal to .
If you do not tell Keai, Keai will speak rudely to you.
Input Format
The first line contains a string .
The second line contains a positive integer .
Their meanings are as described in the statement.
Output Format
Output one integer in a single line, representing the minimum number of operations.
nzhtl1477
15
2
Hint
Sample Explanation
In the first operation, choose character 7. The string becomes nzhtl147777, and the length is .
In the second operation, choose character 7. The string becomes nzhtl1477777777, and the length is .
Constraints and Notes
For of the testdata, , . The string contains only uppercase letters, lowercase letters, and digits, for a total of different characters.
denotes the length of string .
This problem has subtasks, each with the following constraints:
Subtask 1 ( points): It is guaranteed that .
Subtask 2 ( points): It is guaranteed that only character d appears in .
Subtask 3 ( points): .
Subtask 4 ( points): No special constraints.
Notes
Please pay attention to the upper bound of .
The data is generated on Windows. Note that the line ending of each line is \r\n rather than \n.
Translated by ChatGPT 5
京公网安备 11011102002149号