solution
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
string s;
void add(string t)
{
int carry = 0;
for (int i = 0; i < t.size(); i++)
{
s[i] = s[i] + t[i] + carry - '0';
carry=0;
if (s[i] > '9')
{
s[i] -=10;
carry = 1;
}
}
if (carry)
s += '1';
reverse(s.begin(), s.end());
}
int main()
{
int cnt,i;
cin>>s>>cnt;
for(i=0;i<cnt;i++)
{
string t=s;
reverse(t.begin(),t.end());
if(t==s||i==cnt)break;
add(t);
}
cout<<s<<endl<<i;
}