#C1229. Count Distinct Substrings

    ID: 41700 Type: Default 1000ms 256MiB

Count Distinct Substrings

Count Distinct Substrings

You are given an integer k and a string s. Your task is to count the number of distinct contiguous substrings of length k in the string s.

Formally, consider the set of all substrings of length k extracted from s:

$$\{ s[i:i+k] : 0 \leq i \leq |s| - k \}$$

You must output the total number of distinct substrings in this set.

Note: When k is greater than the length of the string, the output should be 0.

inputFormat

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

  • The first line contains an integer k, the length of substrings to be considered.
  • The second line contains the string s consisting of lowercase and/or uppercase letters.

outputFormat

Output the number of distinct substrings of length k found in the string s. The output should be printed to stdout.

## sample
2
abacaba
4

</p>