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 JAVA):

Solution:

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * 4 6
 * 1 2
 * 1 3
 * 1 4
 * 2 3
 * 2 4
 * 3 4
 *
 *
 *
 *
 *
 *
 * @author pttrung
 */
public class D {

    public static long MOD = 100000000;
    public static int[][] dp, store;
    public static String val;

    public static void main(String[] args) {
        PrintWriter out = null;
        try {
            Scanner in = new Scanner();
            //       out = new PrintWriter(new FileOutputStream(new File("output.txt")));
            out = new PrintWriter(System.out);
            val = in.next();
            int k = in.nextInt();
            dp = new int[val.length()][val.length()];
            store = new int[k + 1][val.length()];
            for (int[] a : dp) {
                Arrays.fill(a, -1);
            }
            for (int[] a : store) {
                Arrays.fill(a, -1);
            }
            int result = cal(k, 0);
            out.println(result);
            StringBuilder line = new StringBuilder();
            int start = 0;
            int need = k;
            int num = result;
//            if(num == 0){
//                out.println(val);
//            }

            while (need > 0) {
               // System.out.println(dp[start][val.length() - 1] + " " + start);
                if (need == 1 || dp[start][val.length() - 1] == num) {
                    //System.out.println("HE HE");
                    num -= dp[start][val.length() - 1];
                    need--;

                    int a = start;
                    int e = val.length() - 1;
                  //  System.out.println(a + " " + e);
                    StringBuilder left = new StringBuilder();
                    StringBuilder right = new StringBuilder();
                    while (a <= e) {
                        if (a != e) {
                            if (val.charAt(a) == val.charAt(e)) {
                                left.append(val.charAt(a));
                                right.insert(0, val.charAt(e));
                            } else {
                                left.append(val.charAt(a));
                                right.insert(0, val.charAt(a));
                            }
                        } else {
                            left.append(val.charAt(a));
                        }
                        a++;
                        e--;
                    }
                    //    System.out.println(left.toString() + right.toString());
                    if (line.length() > 0) {
                        line.append("+");
                    }
                    line.append(left).append(right);
                    break;
                }

                for (int i = start; i < val.length() - 1; i++) {
                   // System.out.println(i + " " + start + "  " + dp[start][i] + " " + store[need - 1][i + 1]);
                    if (dp[start][i] != - 1 && store[need - 1][i + 1] + dp[start][i] == num) {
                        //  System.out.println("HA HA");
                        num -= dp[start][i];
                        need--;
                        int a = start;
                        int e = i;
                        start = i + 1;

                 //       System.out.println("HA HA" + a + " " + e);
                        StringBuilder left = new StringBuilder();
                        StringBuilder right = new StringBuilder();
                        while (a <= e) {
                            if (a != e) {
                                if (val.charAt(a) == val.charAt(e)) {
                                    left.append(val.charAt(a));
                                    right.insert(0, val.charAt(e));
                                } else {
                                    left.append(val.charAt(a));
                                    right.insert(0, val.charAt(a));
                                }
                            } else {
                                left.append(val.charAt(a));
                            }
                            a++;
                            e--;
                        }
                        if (line.length() > 0) {
                            line.append("+");
                        }
                        //  System.out.println("HE HE" + left.toString() + " " + right.toString());
                        line.append(left).append(right);
                        break;
                    }
                }
            }

            out.println(line.toString());

            out.close();
        } catch (FileNotFoundException ex) {
            Logger.getLogger(D.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            out.close();
        }
    }

    public static int cal(int need, int start) {
        if (need == 0) {
            return store[need][start] = 0;
        }
        if (need == 1) {
            return store[need][start] = palind(start, val.length() - 1);
        }
        if (store[need][start] != -1) {
            return store[need][start];
        }
        int min = palind(start, val.length() - 1);
        for (int i = start; i < val.length() - 1; i++) {
            int cost = palind(start, i) + cal(need - 1, i + 1);
            min = Math.min(cost, min);
        }
        return store[need][start] = min;
    }

    public static int palind(int start, int end) {
        if (start == end) {
            return dp[start][end] = 0;
        }
        if (start + 1 == end) {
            if (val.charAt(start) == val.charAt(end)) {
                return dp[start][end] = 0;
            } else {
                return dp[start][end] = 1;
            }
        }
        if (dp[start][end] != -1) {
            return dp[start][end];
        }
        if (val.charAt(start) == val.charAt(end)) {
            return dp[start][end] = palind(start + 1, end - 1);
        } else {
            return dp[start][end] = 1 + palind(start + 1, end - 1);
        }

    }

    public static class Point implements Comparable<Point> {

        int start, end;

        public Point(int start, int end) {
            this.start = start;
            this.end = end;
        }

        @Override
        public int compareTo(Point o) {
            if (end != o.end) {
                return end - o.end;
            } else {
                return start - o.start;
            }
        }
    }

    public static class FT {

        int[] data;

        FT(int n) {
            data = new int[n];
        }

        public void update(int index, int value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public int get(int index) {
            int result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static class Sign {

        char c;
        int x, y;

        public Sign(char c, int x, int y) {
            this.c = c;
            this.x = x;
            this.y = y;
        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;
        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}