## DMPG '18 B5 - Mimi and Substrings

View as PDF

Points: 7 (partial)
Time limit: 1.8s
Memory limit: 256M

Author:
Problem type

Mimi 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 .

#### 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