#C6675. Unique k-Substrings

    ID: 50461 Type: Default 1000ms 256MiB

Unique k-Substrings

Unique k-Substrings

Given a string s and an integer k, your task is to count the number of unique substrings of length \(k\) in s. A substring is a contiguous sequence of characters from s. If \(k\) is greater than the length of s, the answer is 0.

For example, if s = "abacab" and k = 3, the unique substrings are "aba", "bac", "aca", and "cab", so the answer is 4.

Input Format: The input is provided via standard input (stdin). The first line contains the string s, and the second line contains an integer k.

Output Format: Output a single integer denoting the count of unique substrings of length \(k\) in the given string.

inputFormat

The input consists of two lines:

  • The first line is a non-empty string s composed of lowercase letters.
  • The second line is an integer k representing the length of substrings to consider.

outputFormat

Output a single integer which is the number of unique substrings of length \(k\) from the string s.

## sample
abacab
3
4