
The Scratch Cat wants to be a cool coder. He searches for some coding desktop backgrounds, which naturally always contain 1
s and 0
s. The Scratch Cat prefers specifically balanced text consisting of 1
s and 0
s. He defines the imbalance function of string 1
s, 0
s, and
The Scratch Cat determines the "coolness" of a background's text
Constraints
Each character of 1
or 0
.
Subtask 1 [10%]
Subtask 2 [40%]
Subtask 3 [50%]
No additional constraints.
Input Specification
The first line will contain two space-separated integers
The second line will contain the string 1
or 0
.
Output Specification
Output the number of non-empty substrings with an imbalance in the range
Do not round the function
Sample Input
33 100
1001
Sample Output
7
Explanation
Below are the imbalances for all substrings of 1001
:
:1
100 :10
0 :0
100 :100
33.33... :00
100 :0
100 :1001
0 :001
33.33... :01
0 :1
100
Comments