#C1481. Unique Substrings Count

    ID: 44500 Type: Default 1000ms 256MiB

Unique Substrings Count

Unique Substrings Count

Given a string s and an integer k, your task is to count the number of unique substrings of length \(k\) that appear exactly once in s. A substring is defined as a contiguous sequence of characters in s. This can be formalized by the formula: \(count = \sum_{u} \mathbf{1}(occurrence(u)=1)\), where \(\mathbf{1}\) is the indicator function. Use efficient data structures such as hash maps to solve this problem in an optimal way.

inputFormat

The input is read from standard input and consists of two lines:

  • The first line contains the string s, which consists of lowercase letters.
  • The second line contains an integer k representing the length of the substring.

outputFormat

Output a single integer to standard output representing the number of unique substrings of length \(k\) that occur exactly once in s.

## sample
abcabc
3
2