#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::ifstream;
using std::max;
using std::min;
using std::ofstream;
using std::string;
using std::stringstream;
using std::vector;
class PathElement {
 public:
  PathElement();
  ~PathElement();
  PathElement *prev;
  int seg_val_;

 private:
};
PathElement::PathElement() {
  seg_val_ = 0;
  prev = nullptr;
};
PathElement::~PathElement(){};
class Palin {
 public:
  Palin();
  ~Palin();
  void input();
  void output();
  int compare(char ch1, char ch2);
  void updateForSmallerPair(int dp[2], int new_dp[2]);
  vector<string> print_path(string str, PathElement *path_element);
  void prune(string &str);
  int Dynamic(string str, int seg_num, string &str_res);

 private:
  string input_str_;
  int seg_num_;
  static int dp[501][501][4][2];
  static PathElement *path_info[2][501][501];
};
int Palin::dp[501][501][4][2];
PathElement *Palin::path_info[2][501][501];
Palin::Palin(){};
Palin::~Palin(){};
void Palin::input() {
  cin >> input_str_;
  cin >> seg_num_;
}
void Palin::output() {
  string str_res = "";
  int output_res = Dynamic(input_str_, seg_num_, str_res);
  cout << output_res << endl;
  cout << str_res << endl;
}
int Palin::compare(char ch1, char ch2) { return ch1 == ch2 ? 0 : 1; }
void Palin::updateForSmallerPair(int dp[2], int new_dp[2]) {
  if (new_dp[0] < dp[0]) {
    dp[0] = new_dp[0];
    dp[1] = new_dp[1];
  }
}
void Palin::prune(string &str) {
  int str_len = str.size();
  int half_size = str_len / 2;
  for (int str_i = 0; str_i < half_size; ++str_i) {
    int op_str_i = str_len - 1 - str_i;
    if (str[str_i] != str[op_str_i]) str[op_str_i] = str[str_i];
  }
}
vector<string> Palin::print_path(string str, PathElement *path_element) {
  vector<string> str_vec;
  int start_i = 0;
  for (; path_element != NULL; path_element = path_element->prev) {
    int k = path_element->prev != NULL ? path_element->seg_val_ : str.length();
    int len = k - start_i;
    string sub_str = str.substr(start_i, len);
    prune(sub_str);
    str_vec.push_back(sub_str);
    start_i = k;
  }
  return str_vec;
}
int Palin::Dynamic(string str, int seg_num, string &str_res) {
  if (!str.size()) return 0;
  memset(dp, -1, sizeof(dp));
  int str_len = str.length();
  for (int start_i = 0; start_i < 500; ++start_i) {
    for (int end_i = start_i; end_i <= min(start_i + str_len, 500); ++end_i) {
      int len_i = end_i - start_i;
      for (int seg_i = 1; seg_i <= 3; ++seg_i) {
        dp[start_i][end_i][seg_i][0] = len_i;
      }
    }
  }
  int curr_path_index = 1;
  int other_path_index = 0;
  for (int len_i = 0; len_i <= str_len; ++len_i) {
    for (int start_i = 0; start_i <= str_len - len_i; ++start_i) {
      int tail_i = start_i + len_i;
      int new_dp[2] = {0, 0};
      if (len_i > 1) {
        new_dp[0] = dp[start_i + 1][tail_i - 1][1][0] +
                    compare(str[start_i], str[tail_i - 1]);
      } else {
        new_dp[0] = 0;
      }
      updateForSmallerPair(dp[start_i][tail_i][1], new_dp);
      dp[start_i][tail_i][3][0] = dp[start_i][tail_i][1][0];
      dp[start_i][tail_i][3][1] = dp[start_i][tail_i][1][1];
      path_info[curr_path_index][start_i][tail_i] = new PathElement();
    }
  }
  int seg_i;
  for (seg_i = 2; seg_i <= seg_num; ++seg_i) {
    curr_path_index = seg_i % 2;
    other_path_index = 1 - curr_path_index;
    for (int start_i = 0; start_i <= str_len; ++start_i) {
      dp[start_i][str_len][2][0] = dp[start_i][str_len][3][0];
      dp[start_i][str_len][2][1] = dp[start_i][str_len][3][1];
    }
    for (int len_i = 0; len_i <= str_len; ++len_i) {
      int start_i = str_len - len_i;
      int min_pre_path_index = -1;
      for (int k_i = start_i + 1; k_i < str_len; ++k_i) {
        int new_dp[2] = {dp[start_i][k_i][1][0] + dp[k_i][str_len][2][0], k_i};
        if (new_dp[0] < dp[start_i][str_len][3][0]) {
          updateForSmallerPair(dp[start_i][str_len][3], new_dp);
          min_pre_path_index = k_i;
        }
      }
      if (min_pre_path_index != -1) {
        path_info[curr_path_index][start_i][str_len] = new PathElement();
        path_info[curr_path_index][start_i][str_len]->seg_val_ =
            min_pre_path_index;
        path_info[curr_path_index][start_i][str_len]->prev =
            path_info[other_path_index][min_pre_path_index][str_len];
      } else {
        path_info[curr_path_index][start_i][str_len] =
            path_info[other_path_index][start_i][str_len];
      }
    }
  }
  vector<string> str_vec =
      print_path(str, path_info[curr_path_index][0][str_len]);
  str_res = "";
  for (int str_i = 0; str_i < int(str_vec.size()); ++str_i) {
    if (str_i) str_res += "+";
    str_res += str_vec[str_i];
  }
  return dp[0][str_len][3][0];
}
int main() {
  Palin p;
  p.input();
  p.output();
  return 0;
}
