#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
typedef long long ll;
typedef long double ld;
using namespace std;
const int N = 1e5 + 10;
const int L = 20;
char s[N];
int n, lg;
int p[L][N], suf[N], lcp[N];
pair<pair<int, int>, int> t[N];
void order(int j){
sort(t, t + n);
for(int i = 0; i < n; i++){
p[j][t[i].s] = i;
if(i > 0 && t[i].f == t[i - 1].f){
p[j][t[i].s] = p[j][t[i - 1].s];
}
}
}
void build(){
for(lg = 0; lg == 0 || 1 << (lg - 1) < n; lg++){
for(int i = 0; i < n; i++){
if(lg == 0){
t[i] = {{s[i], -1}, i}; continue;
}
int cnt = 1 << (lg - 1);
t[i] = {{p[lg - 1][i], -1}, i};
if(i + cnt < n) t[i].f.s = p[lg - 1][i + cnt];
}
order(lg);
}
lg--;
for(int i = 0; i < n; i++) suf[p[lg][i]] = i;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
scanf("%s", s);
n = strlen(s);
build();
int k = 0;
for(int i = 0; i < n; i++){
if(p[lg][i] == n - 1){
k = 0; continue;
}
int j = suf[p[lg][i] + 1];
while(i + k < n && j + k < n && s[i + k] == s[j + k]) k++;
lcp[p[lg][i]] = k;
if(k > 0) k--;
}
int len = * max_element(lcp, lcp + n - 1);
int ind = max_element(lcp, lcp + n - 1) - lcp;
for(int i = 0; i < len; i++){
printf("%c", s[suf[ind] + i]);
}
printf("\n");
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgcGIgcHVzaF9iYWNrCiNkZWZpbmUgZiBmaXJzdAojZGVmaW5lIHMgc2Vjb25kCgp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKdHlwZWRlZiBsb25nIGRvdWJsZSBsZDsKCnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBpbnQgTiA9IDFlNSArIDEwOwpjb25zdCBpbnQgTCA9IDIwOwoKY2hhciBzW05dOwppbnQgbiwgbGc7CmludCBwW0xdW05dLCBzdWZbTl0sIGxjcFtOXTsKcGFpcjxwYWlyPGludCwgaW50PiwgaW50PiB0W05dOwoKdm9pZCBvcmRlcihpbnQgail7CiAgICBzb3J0KHQsIHQgKyBuKTsKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspewogICAgICAgIHBbal1bdFtpXS5zXSA9IGk7CiAgICAgICAgaWYoaSA+IDAgJiYgdFtpXS5mID09IHRbaSAtIDFdLmYpewogICAgICAgICAgICBwW2pdW3RbaV0uc10gPSBwW2pdW3RbaSAtIDFdLnNdOwogICAgICAgIH0KICAgIH0KfQoKdm9pZCBidWlsZCgpewogICAgZm9yKGxnID0gMDsgbGcgPT0gMCB8fCAxIDw8IChsZyAtIDEpIDwgbjsgbGcrKyl7CiAgICAgICAgZm9yKGludCBpID0gMDsgaSA8IG47IGkrKyl7CiAgICAgICAgICAgIGlmKGxnID09IDApewogICAgICAgICAgICAgICAgdFtpXSA9IHt7c1tpXSwgLTF9LCBpfTsgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaW50IGNudCA9IDEgPDwgKGxnIC0gMSk7CiAgICAgICAgICAgIHRbaV0gPSB7e3BbbGcgLSAxXVtpXSwgLTF9LCBpfTsKICAgICAgICAgICAgaWYoaSArIGNudCA8IG4pIHRbaV0uZi5zID0gcFtsZyAtIDFdW2kgKyBjbnRdOwogICAgICAgIH0KICAgICAgICBvcmRlcihsZyk7CiAgICB9CiAgICBsZy0tOwogICAgZm9yKGludCBpID0gMDsgaSA8IG47IGkrKykgc3VmW3BbbGddW2ldXSA9IGk7Cn0KCmludCBtYWluKCl7CiAgICBpb3M6OnN5bmNfd2l0aF9zdGRpbygwKTsKICAgIGNpbi50aWUoMCk7CgogICAgc2NhbmYoIiVzIiwgcyk7CiAgICBuID0gc3RybGVuKHMpOwoKICAgIGJ1aWxkKCk7CgogICAgaW50IGsgPSAwOwogICAgZm9yKGludCBpID0gMDsgaSA8IG47IGkrKyl7CiAgICAgICAgaWYocFtsZ11baV0gPT0gbiAtIDEpewogICAgICAgICAgICBrID0gMDsgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGludCBqID0gc3VmW3BbbGddW2ldICsgMV07CiAgICAgICAgd2hpbGUoaSArIGsgPCBuICYmIGogKyBrIDwgbiAmJiBzW2kgKyBrXSA9PSBzW2ogKyBrXSkgaysrOwogICAgICAgIGxjcFtwW2xnXVtpXV0gPSBrOwogICAgICAgIGlmKGsgPiAwKSBrLS07CiAgICB9CgogICAgaW50IGxlbiA9ICogbWF4X2VsZW1lbnQobGNwLCBsY3AgKyBuIC0gMSk7CiAgICBpbnQgaW5kID0gbWF4X2VsZW1lbnQobGNwLCBsY3AgKyBuIC0gMSkgLSBsY3A7CgogICAgZm9yKGludCBpID0gMDsgaSA8IGxlbjsgaSsrKXsKICAgICAgICBwcmludGYoIiVjIiwgc1tzdWZbaW5kXSArIGldKTsKICAgIH0KICAgIHByaW50ZigiXG4iKTsKCiAgICAKCgoKICAgIHJldHVybiAwOwp9