#include <string>
#include <vector>
#include <iostream>
using namespace std;
int longestBorder(const string& s) {
int len = s.length();
vector<int> prefixFunc(len);
prefixFunc[0] = 0;
int curBorderLen = 0;
for (int i = 1; i < len; ++i) {
while (curBorderLen > 0 && s[curBorderLen] != s[i])
curBorderLen = prefixFunc[curBorderLen - 1];
if (s[curBorderLen] == s[i])
++curBorderLen;
prefixFunc[i] = curBorderLen;
}
return prefixFunc[len-1];
}
int main() {
string s;
cin >> s;
cout << longestBorder(s) << endl;
}
I2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBsb25nZXN0Qm9yZGVyKGNvbnN0IHN0cmluZyYgcykgewoJaW50IGxlbiA9IHMubGVuZ3RoKCk7Cgl2ZWN0b3I8aW50PiBwcmVmaXhGdW5jKGxlbik7IAoJcHJlZml4RnVuY1swXSA9IDA7CiAgICAJICAgICAgICAgICAgICAgICAgICAKCWludCBjdXJCb3JkZXJMZW4gPSAwOwkKCWZvciAoaW50IGkgPSAxOyBpIDwgbGVuOyArK2kpIHsJCgkJd2hpbGUgKGN1ckJvcmRlckxlbiA+IDAgJiYgc1tjdXJCb3JkZXJMZW5dICE9IHNbaV0pIAoJCQljdXJCb3JkZXJMZW4gPSBwcmVmaXhGdW5jW2N1ckJvcmRlckxlbiAtIDFdOyAKCQkgIAoJCWlmIChzW2N1ckJvcmRlckxlbl0gPT0gc1tpXSkgCiAgICAgICAgICAgICsrY3VyQm9yZGVyTGVuOwogICAgICAgIAogIAkJcHJlZml4RnVuY1tpXSA9IGN1ckJvcmRlckxlbjsKICAgCX0KCiAgIAlyZXR1cm4gcHJlZml4RnVuY1tsZW4tMV07Cn0KCmludCBtYWluKCkgewoJc3RyaW5nIHM7CgljaW4gPj4gczsKCWNvdXQgPDwgbG9uZ2VzdEJvcmRlcihzKSA8PCBlbmRsOwp9