#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#define ull unsigned long long
using namespace std;
string s; vector<pair<ull, int> > v;
int main() {
cin >> s;
for(int i = 0; i < s.size(); i++) {
ull t = 0;
for(int j = i; j < s.size(); j++) {
t = t * 257 + s[j];
v.push_back(make_pair(t, j - i + 1));
}
}
sort(v.begin(), v.end());
long long ret = v[0].second;
for(int i = 1; i < v.size(); i++) {
if(v[i].first != v[i - 1].first) {
ret += v[i].second;
}
}
printf("%lld\n", ret);
}
I2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojZGVmaW5lIHVsbCB1bnNpZ25lZCBsb25nIGxvbmcKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKc3RyaW5nIHM7IHZlY3RvcjxwYWlyPHVsbCwgaW50PiA+IHY7CmludCBtYWluKCkgewoJY2luID4+IHM7Cglmb3IoaW50IGkgPSAwOyBpIDwgcy5zaXplKCk7IGkrKykgewoJCXVsbCB0ID0gMDsKCQlmb3IoaW50IGogPSBpOyBqIDwgcy5zaXplKCk7IGorKykgewoJCQl0ID0gdCAqIDI1NyArIHNbal07CgkJCXYucHVzaF9iYWNrKG1ha2VfcGFpcih0LCBqIC0gaSArIDEpKTsKCQl9Cgl9Cglzb3J0KHYuYmVnaW4oKSwgdi5lbmQoKSk7Cglsb25nIGxvbmcgcmV0ID0gdlswXS5zZWNvbmQ7Cglmb3IoaW50IGkgPSAxOyBpIDwgdi5zaXplKCk7IGkrKykgewoJCWlmKHZbaV0uZmlyc3QgIT0gdltpIC0gMV0uZmlyc3QpIHsKCQkJcmV0ICs9IHZbaV0uc2Vjb25kOwoJCX0KCX0KCXByaW50ZigiJWxsZFxuIiwgcmV0KTsKfQ==