Ancient Egyptians are known to have understood difficult concepts in mathematics. The ancient Egyptian mathematician Ahmes liked to write a kind of arithmetic expressions on papyrus paper which he called as Ahmes arithmetic expression.

An Ahmes arithmetic expression can be defined as: 

  * "d" is an Ahmes arithmetic expression, where d is a one-digit positive integer; 
  * "(E1 op E2)" is an Ahmes arithmetic expression, where E1 and E2 are valid Ahmes arithmetic expressions (without spaces) and op is either plus ( + ) or minus ( - ). 

For example 5, (1-1) and ((1+(2-3))-5) are valid Ahmes arithmetic expressions.

On his trip to Egypt, Fafa found a piece of papyrus paper having one of these Ahmes arithmetic expressions written on it. Being very ancient, the papyrus piece was very worn out. As a result, all the operators were erased, keeping only the numbers and the brackets. Since Fafa loves mathematics, he decided to challenge himself with the following task:

Given the number of plus and minus operators in the original expression, find out the maximum possible value for the expression on the papyrus paper after putting the plus and minus operators in the place of the original erased operators.

Input

The first line contains a string E (1 ≤ |E| ≤ 104) — a valid Ahmes arithmetic expression. All operators are erased and replaced with '?'.

The second line contains two space-separated integers P and M (0 ≤ min(P, M) ≤ 100) — the number of plus and minus operators, respectively. 

It is guaranteed that P + M =  the number of erased operators.

Output

Print one line containing the answer to the problem.

Examples

Input

(1?1)
1 0


Output

2


Input

(2?(1?2))
1 1


Output

1


Input

((1?(5?7))?((6?2)?7))
3 2


Output

18


Input

((1?(5?7))?((6?2)?7))
2 3


Output

16

Note

  * The first sample will be (1 + 1) = 2. 
  * The second sample will be (2 + (1 - 2)) = 1. 
  * The third sample will be ((1 - (5 - 7)) + ((6 + 2) + 7)) = 18. 
  * The fourth sample will be ((1 + (5 + 7)) - ((6 - 2) - 7)) = 16. 
import java.io.*;
import java.util.*;

public class _935E {
    /**********************************************************************************************
     *                                            DEBUG                                           *
     **********************************************************************************************/
    private final static boolean DEBUG = false;
    private final static String[] DEBUG_INPUT = {
//            "((1?(5?7))?((6?2)?7))\n" +
//                    "3 2",
//            "(2?(1?2))\n" +
//                    "1 1",
//            "(1?1)\n" +
//                    "1 0",
//            "((1?(5?7))?((6?2)?7))\n" +
//                    "2 3",
            "((4?3)?(((2?(4?((4?((2?(3?(7?3)))?(((((3?(6?2))?3)?(((((6?6)?(1?5))?((8?8)?1))?(5?((7?((6?((((3?8)?8)?(8?5))?7))?8))?((8?(2?8))?3))))?6))?(8?(7?5)))?8)))?((((7?(4?3))?4)?5)?((1?(((2?2)?((((4?((7?6)?(1?4)))?(8?(1?(((1?3)?(((2?2)?(3?(8?(9?((2?(4?6))?(7?8))))))?(9?(7?9))))?(7?3)))))?((2?((2?((8?6)?1))?(3?1)))?(7?1)))?5))?((((6?(9?(((5?4)?7)?((5?8)?8))))?5)?7)?(2?2))))?4)))))?2)?(7?(4?((6?6)?6)))))\n" +
                    "50 49",
//            "(3?((2?6)?9))\n" +
//                    "1 2"
    };



    /**********************************************************************************************
     *                                             MAIN                                           *
     **********************************************************************************************/
    // input
    // ( (1?(5?7)) ? ((6?2)?7) )
    // 3 2
    // output
    // 18
    private static class Solver {
        private static final int MIN = -9 * 10_000;
        private static final int MAX = 9 * 10_000;
        public void solve(Reader in, PrintWriter out) throws IOException {
            char[] ex = in.nextWord().toCharArray();
            int plus = in.nextInt();
            int minus = in.nextInt();

//            int theirs = CF935E.solve(ex, plus, minus);
            int mine = solve(ex, plus, minus);
            out.print(mine);
//            if (theirs != mine) {
//                out.println("WRONG: mine = " + mine + " - theirs = " + theirs);
//            } else {
//                out.println("CORRECT");
//            }
        }

        private int solve(char[] ex, int plus, int minus) {
            Map<Integer, int[]> map = new HashMap<>(); // 0: ?, 1: ), 2: count of ?
            Stack<Integer> stack = new Stack<>();
            for (int i = 0; i < ex.length; i++) {
                if (ex[i] == '(') {
                    stack.push(i);
                    map.put(i, new int[3]);
                } else if (ex[i] == '?') {
                    map.get(stack.peek())[0] = i;
                } else if (ex[i] == ')') {
                    map.get(stack.peek())[1] = i;
                    stack.pop();
                }
            }

            count(0, ex.length-1, map);

            int minSignCount = Math.min(plus, minus);

            int[][][] dp = new int[ex.length][minSignCount+1][2]; // 0: min, 1: max
            for (int i = 0; i < ex.length; i++) {
                for (int j = 0; j < minSignCount + 1; j++) {
                    dp[i][j][0] = MAX;
                    dp[i][j][1] = MIN;
                }
            }

            int res = go(map, dp, ex, minSignCount == plus ? 1 : 0, minSignCount, 1, 0);

//            if (DEBUG) {
//                for (int i = 0; i < ex.length; i++) {
//                    for (int j = 0; j < minSignCount + 1; j++) {
//                        int[] info = map.get(i);
//                        if (info == null) continue;
//                        System.out.println(String.format("[%d,%d] - minSignCount = %d - min = %d - max = %d", i, info[1], j, dp[i][j][0], dp[i][j][1]));
//                    }
//                }
//            }

            return res;
        }

        private int go(Map<Integer, int[]> map, int[][][] dp, char[] ex, int minSign, int minSignCount, int sign, int left) {
            int[] info = map.get(left);
            if (info == null) return ex[left] - '0';

            int totalSignCount = info[2];
            int mid = info[0];
            int[] leftInfo = map.get(left + 1);
            int leftQuesCount = leftInfo == null ? 0 : leftInfo[2];
            int[] rightInfo = map.get(mid+1);
            int rightQuesCount = rightInfo == null ? 0 : rightInfo[2];
            int from, to;

            if (sign == 1) { // need to find max
                if (dp[left][minSignCount][1] != MIN) return dp[left][minSignCount][1];

                int res = MIN;
                if (minSign == 0) { // min sign is -
                    // take ? as min sign -
                    from = Math.max(0, minSignCount-1 - rightQuesCount);
                    to = Math.min(minSignCount-1, leftQuesCount);
                    for (int i = from; i <= to; i++) {
                        res = Math.max(
                                res, go(map, dp, ex, minSign, i, 1, left + 1) - go(map, dp, ex, minSign, minSignCount-1 - i, 0, mid + 1)
                        );
                    }
                    // take ? as NOT min sign +
                    if (totalSignCount > minSignCount) {
                        from = Math.max(0, minSignCount - rightQuesCount);
                        to = Math.min(minSignCount, leftQuesCount);
                        for (int i = from; i <= to; i++) {
                            res = Math.max(
                                    res, go(map, dp, ex, minSign, i, 1, left + 1) + go(map, dp, ex, minSign, minSignCount - i, 1, mid + 1) // take ? as +
                            );
                        }
                    }
                } else { // min sign is +
                    if (totalSignCount > minSignCount) {
                        from = Math.max(0, minSignCount - rightQuesCount);
                        to = Math.min(minSignCount, leftQuesCount);
                        for (int i = from; i <= to; i++) {
                            res = Math.max(
                                    res, go(map, dp, ex, minSign, i, 1, left + 1) - go(map, dp, ex, minSign, minSignCount - i, 0, mid + 1) // take ? as -
                            );
                        }
                    }
                    from = Math.max(0, minSignCount-1 - rightQuesCount);
                    to = Math.min(minSignCount-1, leftQuesCount);
                    for (int i = from; i <= to; i++) {
                        res = Math.max(
                                res, go(map, dp, ex, minSign, i, 1, left + 1) + go(map, dp, ex, minSign, minSignCount-1 - i, 1, mid + 1) // take ? as +
                        );
                    }
                }
                dp[left][minSignCount][1] = res;
                return res;
            } else { // need to find min
                if (dp[left][minSignCount][0] != MAX) return dp[left][minSignCount][0];

                int res = MAX;
                if (minSign == 0) { // min sign is -
                    from = Math.max(0, minSignCount-1 - rightQuesCount);
                    to = Math.min(minSignCount-1, leftQuesCount);
                    for (int i = from; i <= to; i++) {
                        res = Math.min(
                                res, go(map, dp, ex, minSign, i, 0, left + 1) - go(map, dp, ex, minSign, minSignCount-1 - i, 1, mid + 1) // take ? as -
                        );
                    }
                    if (totalSignCount > minSignCount) {
                        from = Math.max(0, minSignCount - rightQuesCount);
                        to = Math.min(minSignCount, leftQuesCount);
                        for (int i = from; i <= to; i++) {
                            res = Math.min(
                                    res, go(map, dp, ex, minSign, i, 0, left + 1) + go(map, dp, ex, minSign, minSignCount - i, 0, mid + 1) // take ? as +
                            );
                        }
                    }
                } else { // min sign is +
                    from = Math.max(0, minSignCount - rightQuesCount);
                    to = Math.min(minSignCount, leftQuesCount);
                    if (totalSignCount > minSignCount) {
                        for (int i = from; i <= to; i++) {
                            res = Math.min(
                                    res, go(map, dp, ex, minSign, i, 0, left + 1) - go(map, dp, ex, minSign, minSignCount - i, 1, mid + 1) // take ? as -
                            );
                        }
                    }
                    from = Math.max(0, minSignCount-1 - rightQuesCount);
                    to = Math.min(minSignCount-1, leftQuesCount);
                    for (int i = from; i <= to; i++) {
                        res = Math.min(
                                res, go(map, dp, ex, minSign, i, 0, left + 1) + go(map, dp, ex, minSign, minSignCount-1 - i, 0, mid + 1) // take ? as +
                        );
                    }
                }
                dp[left][minSignCount][0] = res;
                return res;
            }
        }

        private int count(int left, int right, Map<Integer, int[]> map) {
            if (left == right) return 0;
            int[] info = map.get(left);
            info[2] = 1 + count(left+1, info[0]-1, map) + count(info[0]+1, right-1, map);
            return info[2];
        }
    }

    /**********************************************************************************************
     *                                           TEMPLATE                                         *
     **********************************************************************************************/
    public static void main(String[] args) throws IOException {
        PrintWriter out = null;
        Reader in;
        if (DEBUG) {
            for (String s : DEBUG_INPUT) {
                in = new Reader(new ByteArrayInputStream(s.getBytes()));
                out = new PrintWriter(System.out);
                out.println("===>>> INPUT");
                out.println(s + "\n\n");
                out.println("===>>> OUTPUT");
                long start = System.currentTimeMillis();
                new Solver().solve(in, out);
                long end = System.currentTimeMillis();
                out.println("\n");
                out.println("===========");
                out.println("Took: " + (end - start) + "ms");
                out.println("====================================================================");
                out.println();
                out.println();
                out.flush();
            }
        } else {
            in = new Reader(System.in);
            out = new PrintWriter(System.out);
            new Solver().solve(in, out);
        }
        if (out != null) out.flush();
    }

    /** Reader **/
    private static class Reader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public Reader(InputStream input) {
            reader = new BufferedReader(
                    new InputStreamReader(input));
            tokenizer = new StringTokenizer("");
        }

        private String nextWord() throws IOException {
            while (!tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
            return tokenizer.nextToken();
        }

        private int nextInt() throws IOException {
            return Integer.parseInt(nextWord());
        }

        private long nextLong() throws IOException {
            return Long.parseLong(nextWord());
        }

        private double nextDouble() throws IOException {
            return Double.parseDouble(nextWord());
        }
    }
}

//class CF935E {
//    static final boolean IS_OJ = false;
//    public static BlockReader input;
//
//    public static void main(String[] args) throws FileNotFoundException {
//        if (!IS_OJ) {
//            System.setIn(new FileInputStream("D:\\DataBase\\TESTCASE\\codeforces\\CF935E.in"));
//        }
//        input = new BlockReader(System.in);
//
//        solve();
//    }
//
//    public static void solve() {
//        char[] data = new char[10000];
//        int len = input.nextBlock(data, 0);
//
//        int p = input.nextInteger();
//        int m = input.nextInteger();
//
//    }
//
//    public static int solve(char[] data, int p, int m) {
//        if (m <= p) {
//            Node node = parseSubDp(data, new int[1]);
//            return node.dpMax[m];
//        }
//        else{
//            Node node = parsePlusDp(data, new int[1]);
//            return node.dpMax[p];
//        }
//    }
//
//    public static Node parsePlusDp(char[] data, int[] from) {
//        if (data[from[0]] >= '0' && data[from[0]] <= '9') {
//            from[0]++;
//            return buildConstantNode(data[from[0] - 1] - '0');
//        }
//        from[0]++; //skip (
//        Node node = new Node();
//        node.left = parsePlusDp(data, from);
//        from[0]++; //skip op
//        node.right = parsePlusDp(data, from);
//        from[0]++; //skip )
//
//        node.opNum = 1 + node.left.opNum + node.right.opNum;
//
//        for (int i = 0, bound = Math.min(node.opNum, 100); i <= bound; i++) {
//            int max = Integer.MIN_VALUE;
//            int min = Integer.MAX_VALUE;
//
//            //postive
//            for (int left = 0; left < i; left++) {
//                int right = i - 1 - left;
//                if (left > node.left.opNum || right > node.right.opNum) {
//                    continue;
//                }
//                max = Math.max(max, node.left.dpMax[left] + node.right.dpMax[right]);
//                min = Math.min(min, node.left.dpMin[left] + node.right.dpMin[right]);
//            }
//
//
//            //negative
//            for (int left = 0; left <= i; left++) {
//                int right = i - left;
//                if (left > node.left.opNum || right > node.right.opNum) {
//                    continue;
//                }
//                max = Math.max(max, node.left.dpMax[left] - node.right.dpMin[right]);
//                min = Math.min(min, node.left.dpMin[left] - node.right.dpMax[right]);
//            }
//
//            node.dpMax[i] = max;
//            node.dpMin[i] = min;
//        }
//
//        return node;
//    }
//
//    public static Node parseSubDp(char[] data, int[] from) {
//        if (data[from[0]] >= '0' && data[from[0]] <= '9') {
//            from[0]++;
//            return buildConstantNode(data[from[0] - 1] - '0');
//        }
//        from[0]++; //skip (
//        Node node = new Node();
//        node.left = parseSubDp(data, from);
//        from[0]++; //skip op
//        node.right = parseSubDp(data, from);
//        from[0]++; //skip )
//
//        node.opNum = 1 + node.left.opNum + node.right.opNum;
//
//        for (int i = 0, bound = Math.min(node.opNum, 100); i <= bound; i++) {
//            int max = Integer.MIN_VALUE;
//            int min = Integer.MAX_VALUE;
//
//            //negative
//            for (int left = 0; left < i; left++) {
//                int right = i - 1 - left;
//                if (left > node.left.opNum || right > node.right.opNum) {
//                    continue;
//                }
//                max = Math.max(max, node.left.dpMax[left] - node.right.dpMin[right]);
//                min = Math.min(min, node.left.dpMin[left] - node.right.dpMax[right]);
//            }
//
//
//            //positive
//            for (int left = 0; left <= i; left++) {
//                int right = i - left;
//                if (left > node.left.opNum || right > node.right.opNum) {
//                    continue;
//                }
//                max = Math.max(max, node.left.dpMax[left] + node.right.dpMax[right]);
//                min = Math.min(min, node.left.dpMin[left] + node.right.dpMin[right]);
//            }
//
//            node.dpMax[i] = max;
//            node.dpMin[i] = min;
//        }
//
//        return node;
//    }
//
//    public static Node buildConstantNode(int c) {
//        Node node = new Node();
//        node.opNum = 0;
//        node.dpMax[0] = node.dpMin[0] = c;
//        return node;
//    }
//
//    public static class Node {
//        Node left;
//        Node right;
//        int opNum;
//        int[] dpMax = new int[101];
//        int[] dpMin = new int[101];
//    }
//
//    public static class BlockReader {
//        static final int EOF = -1;
//        InputStream is;
//        byte[] dBuf;
//        int dPos, dSize, next;
//        StringBuilder builder = new StringBuilder();
//
//        public BlockReader(InputStream is) {
//            this(is, 4096);
//        }
//
//        public BlockReader(InputStream is, int bufSize) {
//            this.is = is;
//            dBuf = new byte[bufSize];
//            next = nextByte();
//        }
//
//        public int nextByte() {
//            while (dPos >= dSize) {
//                if (dSize == -1) {
//                    return EOF;
//                }
//                dPos = 0;
//                try {
//                    dSize = is.read(dBuf);
//                } catch (Exception e) {
//                }
//            }
//            return dBuf[dPos++];
//        }
//
//        public String nextBlock() {
//            builder.setLength(0);
//            skipBlank();
//            while (next != EOF && !Character.isWhitespace(next)) {
//                builder.append((char) next);
//                next = nextByte();
//            }
//            return builder.toString();
//        }
//
//        public void skipBlank() {
//            while (Character.isWhitespace(next)) {
//                next = nextByte();
//            }
//        }
//
//        public int nextInteger() {
//            skipBlank();
//            int ret = 0;
//            boolean rev = false;
//            if (next == '+' || next == '-') {
//                rev = next == '-';
//                next = nextByte();
//            }
//            while (next >= '0' && next <= '9') {
//                ret = (ret << 3) + (ret << 1) + next - '0';
//                next = nextByte();
//            }
//            return rev ? -ret : ret;
//        }
//
//        public int nextBlock(char[] data, int offset) {
//            skipBlank();
//            int index = offset;
//            int bound = data.length;
//            while (next != EOF && index < bound && !Character.isWhitespace(next)) {
//                data[index++] = (char) next;
//                next = nextByte();
//            }
//            return index - offset;
//        }
//
//        public boolean hasMore() {
//            skipBlank();
//            return next != EOF;
//        }
//    }
//}
