Count Of Substrings With Exactly K Unique Characters

medium
1. You are given a string(str) and a number K.
2. You have to find the count of valid substrings of the given string.
3. Valid substring is defined as a substring that has exactly K unique characters.

Input Format

A string

Output Format

A number representing count of substrings with exactly K unique characters.

Constraints

1 <= length of string <= 10^5
1 <= k <= 26

Example

Input
aabcbcdbca
2
Output
12
Previous
Longest Substring With Exactly K Unique Characters
Next
Equivalent Subarrays

Related Questions