You are given a string S. Find the number of different substrings in S.

Input
One line containing a string S consisting of lowercase Latin letters.

Output
Output one integer - answer to the question.

Constraints
1 ≤ length of S ≤ 1200

SAMPLE INPUT
abc

SAMPLE OUTPUT
6
def LCP(a,b):
    c = 0
    while (len(a) > c and len(b)>c)  and (a[c] == b[c])  :
        c = c + 1;
    return c

x = raw_input()
setx = set()
for i in range(0,len(x)):
    setx.add(str(x[i:len(x)]))
lst = sorted(setx)


ans = len(lst[0])
for i in range(0, len(lst)-1):
    ans = ans + len(lst[i+1]) - LCP(lst[i],lst[i+1])

print ans