#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double zero = 1e-8;
const double oo = 1e9 + 1;
const int maxn = 515;
int f[maxn][maxn], g[maxn][maxn], n, K, c[maxn][maxn];
char a[maxn];
string s;
int main() {
  gets(a + 1);
  n = strlen(a + 1);
  scanf("%d", &K);
  for (int i = n - 1; i >= 1; --i) {
    for (int j = i + 1; j <= n; ++j)
      g[i][j] = g[i + 1][j - 1] + (a[i] == a[j] ? 0 : 1);
  }
  memset(f, 30, sizeof f);
  for (int i = 1; i <= n; ++i) {
    f[i][1] = g[1][i];
    c[i][0] = 0;
    for (int j = 2; j <= i && j <= K; ++j)
      for (int l = 1; l < i; ++l)
        if (f[l][j - 1] + g[l + 1][i] < f[i][j]) {
          f[i][j] = f[l][j - 1] + g[l + 1][i];
          c[i][j] = l;
        }
  }
  int ans = oo, p = n, l;
  for (int j = 1; j <= K && j <= n; ++j)
    if (f[n][j] < ans) {
      ans = f[n][j];
      l = j;
    }
  printf("%d\n", ans);
  while (l > 0) {
    int t = c[p][l] + 1, y = p;
    while (t < y) {
      if (a[t] != a[y]) a[t] = a[y];
      ++t;
      --y;
    }
    for (int i = p; i > c[p][l]; --i) s = a[i] + s;
    p = c[p][l--];
    if (l > 0) s = '+' + s;
  }
  puts(s.c_str());
  return 0;
}
