#K53282. Count Distinct Substrings

    ID: 29497 Type: Default 1000ms 256MiB

Count Distinct Substrings

Count Distinct Substrings

Given a string (s), count the number of distinct substrings of (s). A substring is defined as a contiguous sequence of characters within the string.

For example, for the string "abc", the distinct substrings are: "a", "b", "c", "ab", "bc", "abc". Hence, the output is 6.

Note that substrings must be continuous and a single character is considered as a valid substring.

inputFormat

The input consists of a single line that contains the string (s). The string can include any printable characters.

outputFormat

Output a single integer representing the number of distinct substrings of the string (s).## sample

abc
6