import java.util.*;
public class RotateList {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String list = scanner.nextLine();
String n = scanner.nextLine();
int rotations = Integer.parseInt(n);
List<Integer> result = new ArrayList<Integer>();
String[] one = list.split(",");
for (int i = 0; i < one.length; i++) {
result.add(Integer.parseInt(one[i]));
}
if (rotations>one.length){
Collections.rotate(result, rotations+2);
}else {
Collections.rotate(result, rotations);
}
System.out.println(Arrays.toString(new List[]{result}).replace("[", "").replace("]", "").replace(" ", ""));
}
}
един тест не минава моля за помощ