#include<stdio.h>intrevs(int a){int b=0;while(a!=0){
b=b*10+a%10;
a/=10;}return b;}intmain(){int n,k,step=0;//N is the initial numer,K is the maximum number of steps.scanf("%d%d",&n,&k);for(int i=0;i<k;i++){if(n==revs(n)){break;}
n=n+revs(n);
step++;}printf("%d\n%d\n",n,step);}