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):
	i = 0
	q = min(len(a),len(b))
	while i<q:
		if a[i]==b[i]:
			pass
		else:
			break
		i+=1
	return i
s = raw_input()

a = []

for i in xrange(len(s)):
	a.append(s[i:])

a.sort()
#print a

i = 0
ans = len(a[0])
while i<len(a)-1:
	
	ans+=len(a[i+1])-LCP(a[i],a[i+1])
	#print a[i],a[i+1],ans
	
	i+=1
print ans