#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#ifdef WIN32
#define LL "%I64d"
#else
#define LL "%lld"
#endif
#define MAXN 110000
#define MAXV MAXN*2
#define MAXE MAXV*200
typedef long long qword;
int n,m;
char str[MAXN];
int sa[MAXN];
int tsa[MAXN];
int rank[MAXN];
int trank[MAXN];
int sum[MAXN];
void Index_Sort(int jp)
{
int i;
memset(sum,0,sizeof(sum));
for (i=1;i<=n;i++)sum[rank[(i+jp-1)%n+1]]++;
for (i=1;i<=m;i++)sum[i]+=sum[i-1];
for (i=n;i>=1;i--)
tsa[sum[rank[(i+jp-1)%n+1]]--]=i;
memset(sum,0,sizeof(sum));
for (i=1;i<=n;i++)sum[rank[sa[i]]]++;
for (i=1;i<=m;i++)sum[i]+=sum[i-1];
for (i=n;i>=1;i--)
sa[sum[rank[tsa[i]]]--]=tsa[i];
}
void Suffix_Array()
{
int i,j,p;
for (i=1;i<=n;i++)trank[i]=str[i-1] - 32;
for (i=1;i<=n;i++)sum[trank[i]]++;
for (i=1;i<=m;i++)sum[i]+=sum[i-1];
for (i=n;i>=1;i--)
sa[sum[trank[i]]--]=i;
rank[sa[1]]=1;
for (i=2,p=1;i<=n;i++)
{
if (trank[sa[i]]!=trank[sa[i-1]])p++;
rank[sa[i]]=p;
}
for (j=1;j<=n;j<<=1)
{
Index_Sort(j);
trank[sa[1]]=1;
for (i=2,p=1;i<=n;i++)
{
if (rank[sa[i]]!=rank[sa[i-1]] || rank[(sa[i]+j-1)%n+1]!=rank[(sa[i-1]+j-1)%n+1])p++;
trank[sa[i]]=p;
}
for (i=1;i<=n;i++)
rank[i]=trank[i];
}
}
int main()
{
freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int i,j,k;
int x,y,z;
// for(i=1;i<100;i++)
// printf("%d %c\n",i,i);
scanf("%s\n",&str);
n=strlen(str);
m=max(n,300);
Suffix_Array();
for (i=1;i<=n;i++)
printf("%c",str[(sa[i]-2+n)%n]);
return 0;
}