public static void main(String[] args) {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String[] line = br.readLine().split("\\s+");
			String nl = line[0];
			int k = Integer.valueOf(line[1]);
			int step = 0;
			
			char[] cs = nl.toCharArray();
			int[] xs = new int[cs.length];
			for(int i = 0; i < cs.length; i++) {
				xs[i] = cs[i] - '0';
			}
			int[] ys = xs;
			while(!isPalindromic(ys) && step < k) {
				ys = addSelfWithReverse(ys);				
				step += 1;
			}
			
			for(int i = 0; i < ys.length; i++) {
				System.out.print(ys[i]);
			}
			System.out.println();
			System.out.println(step);			
		} catch(Exception ex) {
			ex.printStackTrace();
		}
		
	}