// Arup Guha
// 4/9/2017
// Solution to 1992 UCF HS Contest Problem: Numbers of Numbers in Numbers

import java.util.*;

public class numbers {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);

		// Process all cases.
		while (stdin.hasNext()) {

			// Get input.
			String num = stdin.next();
			int rep = stdin.nextInt();

			// Simulate iterations.
			for (int i=1; i<rep; i++) num = iter(num);

			// Output result - annoying format.
			System.out.println(num);
			if (stdin.hasNext()) System.out.println();
		}
	}

	public static String iter(String s) {

		String res = "";
		int i = 0;

		// Go till end of input string.
		while (i < s.length()) {

			// Iterate till change of digit.
			int j = i;
			while (j < s.length() && s.charAt(j) == s.charAt(i)) j++;

			// Add to number.
			res = res + (j-i) + s.charAt(i);

			// Update i.
			i = j;
		}

		// Ta da!
		return res;
	}
}