#include <bits/stdc++.h>   using namespace std;   int lim;   char c[1000];   int g[1000][1000];   int f[1000][1000], pre[1000][1000];   void back(int v, int k) {     int p = pre[v][k];     if (p) {       back(p, k - 1);       printf( + );     }     int i1 = p + 1;     int j1 = v;     for (; i1 < j1; i1++, j1--)       if (c[i1 - 1] != c[j1 - 1]) c[j1 - 1] = c[i1 - 1];     for (int i = p + 1; i <= v; i++) printf( %c , c[i - 1]);   }   int main() {     scanf( %s , c);     scanf( %d , &lim);     for (int i = 1; i < strlen(c); i++)       for (int j = i + 1; j <= strlen(c); j++) {         int i1 = i;         int j1 = j;         for (; i1 < j1; i1++, j1--)           if (c[i1 - 1] != c[j1 - 1]) g[i][j]++;       }     memset(f, 127, sizeof(f));     f[0][0] = 0;     for (int i = 1; i <= strlen(c); i++)       for (int j = 0; j < i; j++)         for (int k = 0; k < lim && k <= j; k++)           if (f[j][k] + g[j + 1][i] < f[i][k + 1])             f[i][k + 1] = f[j][k] + g[j + 1][i], pre[i][k + 1] = j;     int min = 2000000000;     int pos = lim + 1;     for (int i = 0; i <= lim; i++)       if (f[strlen(c)][i] < min) {         min = f[strlen(c)][i], pos = i;       }     printf( %d n , min);     back(strlen(c), pos);     printf(  n );   }   