#D5996. Additions
Additions
Additions
You are given an integer and a string consisting of '+' and digits. You are asked to transform the string into a valid formula whose calculation result is smaller than or equal to by modifying some characters. Here, you replace one character with another character any number of times, and the converted string should still consist of '+' and digits. Note that leading zeros and unary positive are prohibited.
For instance, '0123+456' is assumed as invalid because leading zero is prohibited. Similarly, '+1+2' and '2++3' are also invalid as they each contain a unary expression. On the other hand, '12345', '0+1+2' and '1234+0+0' are all valid.
Your task is to find the minimum number of the replaced characters. If there is no way to make a valid formula smaller than or equal to , output instead of the number of the replaced characters.
Input
The input consists of a single test case in the following format.
The first line contains an integer , which is the upper limit of the formula (). The second line contains a string , which consists of '+' and digits and whose length is between and , inclusive. Note that it is not guaranteed that initially is a valid formula.
Output
Output the minimized number of the replaced characters. If there is no way to replace, output instead.
Examples
Input
100 +123
Output
2
Input
10 +123
Output
4
Input
1 +123
Output
-1
Input
10 ++1+
Output
2
Input
2000 1234++7890
Output
2
inputFormat
outputFormat
output instead of the number of the replaced characters.
Input
The input consists of a single test case in the following format.
The first line contains an integer , which is the upper limit of the formula (). The second line contains a string , which consists of '+' and digits and whose length is between and , inclusive. Note that it is not guaranteed that initially is a valid formula.
Output
Output the minimized number of the replaced characters. If there is no way to replace, output instead.
Examples
Input
100 +123
Output
2
Input
10 +123
Output
4
Input
1 +123
Output
-1
Input
10 ++1+
Output
2
Input
2000 1234++7890
Output
2
样例
2000
1234++7890
2