#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <queue>
#define rep(i, l, r) for(int i = l; i <= r; i++)
#define down(i, l, r) for(int i = l; i >= r; i--)
#define MS 123456
#define MAX 1037471823
#define Q 103
using namespace std;
struct node
{
int x, y, z;
bool operator < (const node &k) const { return x < k.x || (x == k.x && y < k.y) || (x == k.x && y == k.y && z < k.z); }
} k[MS];
char st[MS];
int s[MS], l, r[MS], o, a;
int main()
{
scanf("%s", st); l = strlen(st);
rep(i, 1, l) s[i] = int(st[i-1]);
s[0] = s[l];
rep(i, 1, l) k[i].x = s[i], k[i].y = 0, k[i].z = i;
sort(k+1, k+1+l); rep(i, 1, l) if (k[i].x == k[i-1].x && k[i].y == k[i-1].y) r[k[i].z] = r[k[i-1].z]; else r[k[i].z] = i;
o = 1;
while (true)
{
rep(i, 1, l) k[i].x = r[k[i].z], k[i].y = r[(k[i].z+o-1)%l+1];
a = 1; rep(i, 2, l+1) if (k[i-1].x != k[i].x)
{
if (i-1 > a) sort(k+a, k+i);
a = i;
}
rep(i, 1, l) if (k[i].x == k[i-1].x && k[i].y == k[i-1].y) r[k[i].z] = r[k[i-1].z]; else r[k[i].z] = i;
if (o > l) break;
o *= 2;
}
rep(i, 1, l) printf("%c", s[k[i].z-1]);
printf("\n");
return 0;
}
I2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8Y3N0cmluZz4KI2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPGZzdHJlYW0+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNpbmNsdWRlIDxxdWV1ZT4KCiNkZWZpbmUgcmVwKGksIGwsIHIpIGZvcihpbnQgaSA9IGw7IGkgPD0gcjsgaSsrKQojZGVmaW5lIGRvd24oaSwgbCwgcikgZm9yKGludCBpID0gbDsgaSA+PSByOyBpLS0pCiNkZW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