#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 200000 + 10;
int sa[maxn], rank[maxn], tp[maxn], tax[maxn];
int n, m;
char s[maxn];
inline void Rsort(){
for(int i = 0; i <= m; i++) tax[i] = 0;
for(int i = 1; i <= n; i++) tax[rank[tp[i]]]++;
for(int i = 1; i <= m; i++) tax[i] += tax[i - 1];
for(int i = n; i; i--) sa[tax[rank[tp[i]]]--] = tp[i];
}
bool inline cmp(int *a, int l, int r, int w){
return a[l] == a[r] && a[l + w] == a[r + w];
}
void suffix(){
m = 127;
for(int i = 1; i <= n; i++){
rank[i] = s[i];
tp[i] = i;
}
Rsort();
for(int p, w = 1; p < n; w <<= 1, m = p){
p = 0;
for(int i = n - w + 1; i <= n; i++) tp[++p] = i;
for(int i = 1; i <= n; i++)
if(sa[i] > w) tp[++p] = sa[i] - w;
Rsort();
swap(rank, tp);
p = rank[sa[1]] = 1;
for(int i = 2; i <= n; i++)
rank[sa[i]] = cmp(tp, sa[i], sa[i - 1], w) ? p : ++p;
}
}
int main(){
scanf("%s", s + 1);
n = strlen(s + 1);
for(int i = 1; i <= n; i++)
s[i + n] = s[i];
n <<= 1;
suffix();
n >>= 1;
for(int i = 1; i <= (n << 1); i++)
if(sa[i] <= n) printf("%c", s[sa[i] + n - 1]);
return 0;
}