#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#define FOR(i,a,b) for(i=(a);i<=(b);i++)
#define ROF(i,a,b) for(i=(a);i>=(b);i--)
#define mmt(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define mp make_pair
#define N 500010
using namespace std;
typedef long long LL;
typedef long double LD;
int r[N],w1[N],w2[N],ws[N],wv[N],sa[N];
bool cmp(int *r,int a,int b,int L){return r[a]==r[b]&&r[a+L]==r[b+L];}
void DA(int *r,int *sa,int n,int m)
{
  int i,j,p,*t,*x=w1,*y=w2;
  FOR(i,0,m-1) ws[i]=0;FOR(i,0,n-1) ++ws[x[i]=r[i]];
  FOR(i,1,m-1) ws[i]+=ws[i-1];ROF(i,n-1,0) sa[--ws[x[i]]]=i;
  for(j=p=1;p<n;j<<=1,m=p)
  {
    p=0;FOR(i,n-j,n-1) y[p++]=i;
    FOR(i,0,n-1) if (sa[i]>=j) y[p++]=sa[i]-j;
    FOR(i,0,m-1) ws[i]=0;FOR(i,0,n-1) ++ws[wv[i]=x[y[i]]];
    FOR(i,1,m-1) ws[i]+=ws[i-1];ROF(i,n-1,0) sa[--ws[wv[i]]]=y[i];
    for(t=x,x=y,y=t,x[sa[0]]=0,p=i=1;i<n;i++) 
     x[sa[i]]=cmp(y,sa[i],sa[i-1],j)?p-1:p++;
  }
}
int main()
{
  int n=0,i;char ch;
  while (scanf("%c",&ch)!=EOF) if (ch=='\n') break;else r[n++]=ch;
  int m=2*n-1;
  FOR(i,n,m-1) r[i]=r[i-n];
  DA(r,sa,m+1,300);
  FOR(i,0,m) if (sa[i]+n-1<=m-1) printf("%c",r[sa[i]+n-1]);
  return 0;
}