#C7844. Count Distinct Substrings
Count Distinct Substrings
Count Distinct Substrings
Given a string (s) consisting only of lowercase English letters and an integer (k), your task is to count the number of distinct contiguous substrings of (s) with length (k). In other words, if (|s|=n), you need to find the number of unique substrings among all substrings (s[i..i+k-1]) for (0 \leq i \leq n-k). If (k > n), output 0.
inputFormat
The input is read from standard input. The first line contains a non-empty string (s) consisting only of lowercase English letters. The second line contains an integer (k) which represents the length of substrings to consider.
outputFormat
Output a single integer representing the number of distinct substrings of length (k) in (s) to standard output.## sample
ababc
2
3
</p>