var s,s1:string; n,i:integer;begin readln(s); readln(n); for i:=1 to n do begin insert(s[1],s1,length(s1)+1); delete(s,1,1); end; s:=s+s1; writeln(s);end.
var
s,s1:string;
n,i:integer;
begin
readln(s);
readln(n);
for i:=1 to n do
begin
insert(s[1],s1,length(s1)+1);
delete(s,1,1);
end;
s:=s+s1;
writeln(s);
end.