#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
vector<string>T;
string S;
int main(){
cin>>S;
for(int i=0;i<S.size();i++){
for(int j=i+1;j<=S.size();j++){
T.push_back(S.substr(i,j-i));
}
}
sort(T.begin(),T.end());
int sum=0;
for(int i=0;i<T.size();i++){
if(i==0){sum+=T[i].size();}
else{
if(T[i]!=T[i-1]){
sum+=T[i].size();
}
}
}
cout<<sum<<endl;
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPHN0cmluZz4KI2luY2x1ZGU8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp2ZWN0b3I8c3RyaW5nPlQ7CnN0cmluZyBTOwppbnQgbWFpbigpewoJY2luPj5TOwoJZm9yKGludCBpPTA7aTxTLnNpemUoKTtpKyspewoJZm9yKGludCBqPWkrMTtqPD1TLnNpemUoKTtqKyspewoJCQlULnB1c2hfYmFjayhTLnN1YnN0cihpLGotaSkpOwoJCX0KCX0KCXNvcnQoVC5iZWdpbigpLFQuZW5kKCkpOwoJaW50IHN1bT0wOwoJZm9yKGludCBpPTA7aTxULnNpemUoKTtpKyspewoJCWlmKGk9PTApe3N1bSs9VFtpXS5zaXplKCk7fQoJCWVsc2V7CgkJCWlmKFRbaV0hPVRbaS0xXSl7CgkJCQlzdW0rPVRbaV0uc2l6ZSgpOwoJCQl9CgkJfQoJfQoJY291dDw8c3VtPDxlbmRsOwoJcmV0dXJuIDA7Cn0=