Problem: Friday is Polycarpus' favourite day of the week. Not because it is followed by the weekend, but because the lessons on Friday are 2 IT lessons, 2 math lessons and 2 literature lessons. Of course, Polycarpus has prepared to all of them, unlike his buddy Innocentius. Innocentius spent all evening playing his favourite game Fur2 and didn't have enough time to do the literature task. As Innocentius didn't want to get an F, he decided to do the task and read the book called "Storm and Calm" during the IT and Math lessons (he never used to have problems with these subjects). When the IT teacher Mr. Watkins saw this, he decided to give Innocentius another task so that the boy concentrated more on the lesson and less — on the staff that has nothing to do with IT. 

Mr. Watkins said that a palindrome is a string that can be read the same way in either direction, from the left to the right and from the right to the left. A concatenation of strings a, b is a string ab that results from consecutive adding of string b to string a. Of course, Innocentius knew it all but the task was much harder than he could have imagined. Mr. Watkins asked change in the "Storm and Calm" the minimum number of characters so that the text of the book would also be a concatenation of no more than k palindromes. Innocentius can't complete the task and therefore asks you to help him.

Input

The first input line contains a non-empty string s which is the text of "Storm and Calm" (without spaces). The length of the string s does not exceed 500 characters. String s consists of uppercase and lowercase Latin letters. The second line contains a single number k (1 ≤ k ≤ |s|, where |s| represents the length of the string s).

Output

Print on the first line the minimum number of changes that Innocentius will have to make. Print on the second line the string consisting of no more than k palindromes. Each palindrome should be non-empty and consist of uppercase and lowercase Latin letters. Use the character "+" (ASCII-code 43) to separate consecutive palindromes. If there exist several solutions, print any of them.

The letters' case does matter, that is an uppercase letter is not considered equivalent to the corresponding lowercase letter.

Examples

Input

abacaba
1


Output

0
abacaba


Input

abdcaba
2


Output

1
abdcdba


Input

abdcaba
5


Output

0
a+b+d+c+aba


Input

abacababababbcbabcd
3


Output

1
abacaba+babab+bcbabcb

Solution (in CPP):

Solution:
#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;
}