#include <stdio.h>
#include <string.h>
int main()
{
char a[50];
int n;
while(scanf("%s%d",a,&n)!=EOF)
{
//getchar();
int l,i,k;
//scanf("%d",&n);
l=strlen(a);
k=n%l;
for(i=l-k;i<l;i++)
printf("%c",a[i]);
for(i=0;i<l-k;i++)
printf("%c",a[i]);
printf("
");
}
return 0;
}