#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
class CA
{
public:
void run();
vector<int> num;
bool isPalindromic();
};
bool CA::isPalindromic()
{
vector<int> tn;
tn=num;
reverse(tn.begin(),tn.end());
if(tn==num) return true;
else return false;
}
void CA::run()
{
string s;
int k,k1,carry;
cin>>s>>k;
int i;
for(i=0;i<s.size();i++) num.push_back(s[i]-'0');
vector<int> tn,tn1;
k1=0;
while(1)
{
if(isPalindromic())
{
break;
}
else
{
if(k1>=k) break;
tn=num;
reverse(tn.begin(),tn.end());
carry=0;
tn1.clear();
for(i=0;i<num.size();i++)
{
tn1.push_back((num[i]+tn[i]+carry)%10);
carry=(num[i]+tn[i]+carry)/10;
}
if(carry>0) tn1.push_back(carry);
reverse(tn1.begin(),tn1.end());
num=tn1;
}
k1++;
}
for(i=0;i<num.size();i++) cout<<num[i];
cout<<endl<<k1;
}
int main()
{
// freopen("test.in","r",stdin);
CA *a=new CA;
a->run();
return 0;
}