#include <iostream>
#include <string>
using namespace std;
int main(){
string str;
int n;
while(cin >> str >> n){
int len = str.size();
n %= len;
int count = len - n, j = 0;
while(j < len){
cout << str.at(count++ % len);
++j;
}
cout << endl;
}
return 0;
}