#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
#define N 200010
char ch[N];
int a[N],v[N],n,k,p,q;
int sa[2][N],rnk[2][N];
inline void calc_sa(int sa[N],int rnk[N],int SA[N],int RNK[N])
{
for (int i=1;i<=n;i++)v[rnk[sa[i]]]=i;
for (int i=n;i>=1;i--)
if (sa[i]>k)SA[v[rnk[sa[i]-k]]--]=sa[i]-k;
for (int i=n-k+1;i<=n;i++)SA[v[rnk[i]]]=i;
for (int i=1;i<=n;i++)
RNK[SA[i]]=RNK[SA[i-1]]+(rnk[SA[i]]!=rnk[SA[i-1]]||rnk[SA[i-1]+k]!=rnk[SA[i]+k]);
}
inline void get_sa()
{
p=0,q=1;a[0]=-1;
memset(v,0,sizeof(v));
for (int i=1;i<=n;i++)v[a[i]]++;
for (int i=1;i<=256;i++)v[i]+=v[i-1];
for (int i=1;i<=n;i++)sa[p][v[a[i]]--]=i;
for (int i=1;i<=n;i++)
rnk[p][sa[p][i]]=rnk[p][sa[p][i-1]]+(a[sa[p][i]]!=a[sa[p][i-1]]);
for (k=1;k<n;k<<=1,swap(p,q))
calc_sa(sa[p],rnk[p],sa[q],rnk[q]);
}
int main()
{
scanf("%s",ch+1);
n=strlen(ch+1);
for (int i=1;i<=n;i++)
{
a[i]=ch[i];
a[i+n]=a[i];
ch[i+n]=ch[i];
}
n*=2;
get_sa();
ch[0]=ch[n];
for (int i=1;i<=n;i++)
if(sa[p][i]<=n/2)printf("%c",ch[sa[p][i]-1]);
return 0;
}