#include <iostream>
#include <string>
using namespace std;int main() {string s1, s2;getline(cin, s1);int n;cin >> n;if(n>s1.size()){n=n-s1.size();s2 = s1.substr(0, n);s1.erase(0, n);cout << s1+s2;}else{// 提取s1的前n个字符到s2中s2 = s1.substr(0, n);s1.erase(0, n);cout << s1+s2;
}return 0;
}