#C10427. Count Distinct Substrings

    ID: 39631 Type: Default 1000ms 256MiB

Count Distinct Substrings

Count Distinct Substrings

Given an integer \(k\) and a string \(s\), count the number of distinct substrings of length \(k\) in \(s\). A substring is a contiguous sequence of characters from the string. If \(k\) is greater than the length of \(s\), then output 0.

For example, if \(k = 3\) and \(s = "ababc"\), the distinct substrings of length 3 are "aba", "bab", and "abc", so the answer is 3.

inputFormat

The input consists of two lines:

  1. The first line contains an integer \(k\), which is the length of the substring.
  2. The second line contains the string \(s\).

outputFormat

Output a single integer representing the number of distinct substrings of length \(k\) in the given string \(s\).

## sample
3
ababc
3