Skip to content
UPEEC

Distinct Substrings

Medium#strings#hashing· solved by 0 · time limit 2.0 s

How many different non-empty substrings does the string have? (aba has a, b, ab, ba, aba → 5.)

Input

One string of lowercase letters.

Output

The number of distinct substrings.

Constraints

1 to 300 letters.

Sample 1

Input

aba

Output

5

Sample 2

Input

aaa

Output

3

Sign in or join free to run and submit your solution.