DMPG '18 B5 - Mimi and Substrings
View as PDFMimi is playing with a string  when her little sister asks her a question:
How many substrings of
are there such that these substrings are of length
and have exactly 1 distinct letter?
Constraints
Let  denote the length of 
.
For all subtasks:
Subtask 1 [10%]
Subtask 2 [90%]
Input Specification
The first line of input will contain a single string, , consisting of only lowercase English letters.
The second line of input will contain an integer, .
Output Specification
The number of substrings which satisfy the given condition.
Sample Input
aaaabb
2
Sample Output
4
Comments