#include <bits/stdc++.h>
using namespace std;
string s;
int dp[501][501];
int p[501][501], pl[501][501];
int solve(int i, int k) {
  int &res = dp[i][k];
  if (res != -1) return res;
  if (i == s.length()) return res = 0;
  if (k == 1) {
    res = pl[i][s.length() - 1];
    p[i][k] = s.length() - 1;
    return res;
  }
  res = s.length() + 1;
  for (int j = i; j < s.length(); j++) {
    int x = pl[i][j] + solve(j + 1, k - 1);
    if (x < res) {
      res = x;
      p[i][k] = j;
    }
  }
  return res;
}
int main() {
  cin >> s;
  memset(dp, -1, sizeof dp);
  for (int k = 0; k < s.length(); k++) {
    for (int i = 0; i < s.length(); i++) {
      int j = i + k;
      if (j >= s.length()) continue;
      if (k > 1)
        pl[i][j] = pl[i + 1][j - 1] + (s[i] != s[j] ? 1 : 0);
      else if (i == j)
        pl[i][j] = 0;
      else
        pl[i][j] = (s[i] == s[j] ? 0 : 1);
    }
  }
  int k;
  cin >> k;
  int ans = solve(0, k);
  cout << ans << endl;
  int x = 0;
  while (x < s.length()) {
    int y = p[x][k];
    int l = y - x + 1;
    for (int i = x; i <= y; i++) s[i] = s[y - i + x];
    cout << s.substr(x, l);
    x = y + 1;
    if (x < s.length()) cout << "+";
    k--;
  }
  cout << endl;
  return 0;
}
