#K37832. Maximum Distinct Substrings
Maximum Distinct Substrings
Maximum Distinct Substrings
You are given a string a and an integer k. Your task is to compute the number of distinct substrings of length k in the string a.
For a string of length n, there are at most \(n - k + 1\) substrings of length k. We define the distinct substrings as the unique substrings among all continuous sequences of characters of length k in a, i.e., the set \(\{a[i:i+k] \mid 0 \le i \le n-k\}\).
Note that if \(k \le 0\) or \(k > n\), the answer is 0.
inputFormat
The input is given from stdin in two lines. The first line contains the string a, and the second line contains an integer k.
outputFormat
Output to stdout a single integer representing the number of distinct substrings of length \(k\) in the string a.
## sampleabcdefg
3
5