Submit solution
Points:
7 (partial)
Time limit:
1.8s
Memory limit:
256M
Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
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
.
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