import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
int n=sc.nextInt();
while(n-->0){
StringBuilder sb=new StringBuilder();
for(int j=0;j<s.length();j++){
int k=j;
while(k<s.length()&&s.charAt(k)==s.charAt(j)) k++;
sb.append(k-j).append(s.charAt(j));
j=k-1;
}
s=sb.toString();
}
System.out.println(s);
}
}