I am trying to resolve the below string manipulation.

But code doesn't work as expected. Need help with some inputs.

Input

First line of input contains string M, consisting of lowercase English letters. Second line of input contains integer N, consisting of characters to be removed.

Output

Print 1 if string is k-drome, 0 otherwise. Here the constraint is 1 <= length of M <= 100

Code:

//function to resolve the string
bool isKdrom(char * M, int N, int k)
{
while (N >=1 && M[0] == M[N-1])
{
M++; N-=2;
}
if (N <= 1) return true;
if (k > 0)
return isKdrom(M+ 1, N-1, k-1) || isKdrom(M, N-1, k-1);
return false;
}