#K1941. Unique Substrings

    ID: 24626 Type: Default 1000ms 256MiB

Unique Substrings

Unique Substrings

Given a string s consisting of lowercase alphabets, your task is to determine the number of distinct substrings that can be formed from s. A substring is defined as a contiguous sequence of characters. Note that the total number of substrings in a string of length n is \(\frac{n(n+1)}{2}\), but when characters repeat, some substrings may be identical.

For example, for the string abc, the distinct substrings are "a", "b", "c", "ab", "bc" and "abc", so the answer is 6.

Your solution should read the input from stdin and output the result to stdout.

inputFormat

The input consists of a single line containing the string s. The string s may be empty and will only contain lowercase alphabets.

Input is read from stdin.

outputFormat

Output a single integer — the number of distinct substrings that can be formed from the given string.

Output should be written to stdout.

## sample
abc
6