Takahashi has decided to give a string to his mother.

The value of a string T is the length of the longest common subsequence of T and T', where T' is the string obtained by reversing T. That is, the value is the longest length of the following two strings that are equal: a subsequence of T (possibly non-contiguous), and a subsequence of T' (possibly non-contiguous).

Takahashi has a string S. He wants to give her mother a string of the highest possible value, so he would like to change at most K characters in S to any other characters in order to obtain a string of the highest possible value. Find the highest possible value achievable.

Constraints

* 1 \leq |S| \leq 300
* 0 \leq K \leq |S|
* S consists of lowercase English letters.
* K is an integer.

Input

Input is given from Standard Input in the following format:


S
K


Output

Print the highest possible value achievable.

Examples

Input

abcabcabc
1


Output

7


Input

atcodergrandcontest
3


Output

15
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String T = in.next();
            int N = T.length();
            int K = in.nextInt();

            int[][][] dp = new int[N][N][K + 1];

            for (int right = 0; right < N; right++) {
                for (int left = right; left >= 0; left--) {
                    if (left == right) {
                        dp[left][right][0] = 1;
                    } else {
                        for (int k = 0; k <= K; k++) {
                            dp[left][right][k] = Math.max(dp[left + 1][right][k], dp[left][right - 1][k]);
                            if (T.charAt(left) == T.charAt(right)) {
                                dp[left][right][k] = Math.max(dp[left][right][k], 2 + dp[left + 1][right - 1][k]);
                            } else if (k > 0) {
                                dp[left][right][k] = Math.max(dp[left][right][k], 2 + dp[left + 1][right - 1][k - 1]);
                            }
                        }
                    }
                }
            }
            int best = 0;
            for (int k = 0; k <= K; k++) {
                best = Math.max(best, dp[0][N - 1][k]);
            }
            out.println(best);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}

