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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vaibhav Pulastya
 */
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);
        AFafaAndAncientMathematics solver = new AFafaAndAncientMathematics();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFafaAndAncientMathematics {
        int num = 0;
        String E;
        ArrayList<Integer>[] tree;
        HashMap<Integer, Integer> value;
        int[][][] dp;
        int[] opCount;
        int P;
        int M;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            E = in.next();
            P = in.nextInt();
            M = in.nextInt();
            opCount = new int[E.length() + 1];
            tree = new ArrayList[E.length() + 1];
            for (int i = 0; i < E.length(); i++) {
                tree[i] = new ArrayList<>(2);
            }
            value = new HashMap<>();
            dp = new int[E.length() + 1][102][2];
            int all = 0;
            for (int i = 0; i < E.length(); i++) {
                if (E.charAt(i) == '?') all++;
            }
            buildTree(0, E.length() - 1, 0, all);
            if (P <= M) dfsP(0);
            else dfsM(0);
            out.println(dp[0][Math.min(P, M)][0]);
        }

        void buildTree(int l, int r, int from, int allQ) {

            if (l < r) {

                if (E.charAt(l) == '(') {

                    opCount[from] = allQ;
                    int count = 0;
                    int quest = 0;
                    boolean done = true;
                    for (int i = l + 1; i < r; i++) {
                        if (E.charAt(i) == '(') count++;
                        if (E.charAt(i) == ')') count--;
                        if (count == 0 && done) {
                            tree[from].add(++num);
                            buildTree(l + 1, i, num, quest);
                            tree[from].add(++num);
                            buildTree(i + 2, r - 1, num, allQ - quest - 1);
                            done = false;
                        }
                        if (E.charAt(i) == '?') quest++;
                    }

                }

            } else if (l == r) {

                int val = E.charAt(l) - '0';
                value.put(num, val);

            }
        }

        void dfsP(int u) {

            if (tree[u].size() == 0) {
                dp[u][0][0] = value.get(u);
                dp[u][0][1] = value.get(u);
                return;
            }

            for (int v : tree[u]) {
                dfsP(v);
            }

            int left = tree[u].get(0);
            int right = tree[u].get(1);

            for (int plus = 0; plus <= Math.min(opCount[u], P); plus++) {

                dp[u][plus][0] = Integer.MIN_VALUE;
                dp[u][plus][1] = Integer.MAX_VALUE;

                for (int lp = 0; lp <= plus && lp <= Math.min(opCount[left], P); lp++) {

                    for (int i = 0; i < 2; i++) {

                        for (int i1 = 0; i1 < 2; i1++) {
                            if (plus - lp <= opCount[right])
                                dp[u][plus][0] = Math.max(dp[left][lp][i] - dp[right][plus - lp][i1], dp[u][plus][0]);
                            if (plus - lp - 1 >= 0 && plus - lp - 1 <= opCount[right]) {
                                dp[u][plus][0] = Math.max(dp[left][lp][i] + dp[right][plus - lp - 1][i1], dp[u][plus][0]);
                            }

                            if (plus - lp <= opCount[right])
                                dp[u][plus][1] = Math.min(dp[left][lp][i] - dp[right][plus - lp][i1], dp[u][plus][1]);
                            if (plus - lp - 1 >= 0 && plus - lp - 1 <= opCount[right])
                                dp[u][plus][1] = Math.min(dp[left][lp][i] + dp[right][plus - lp - 1][i1], dp[u][plus][1]);

                        }

                    }

                }

            }
        }

        void dfsM(int u) {

            if (tree[u].size() == 0) {
                dp[u][0][0] = value.get(u);
                dp[u][0][1] = value.get(u);
                return;
            }

            for (int v : tree[u]) {
                dfsM(v);
            }

            int left = tree[u].get(0);
            int right = tree[u].get(1);

            for (int minus = 0; minus <= Math.min(opCount[u], M); minus++) {

                dp[u][minus][0] = Integer.MIN_VALUE;
                dp[u][minus][1] = Integer.MAX_VALUE;

                for (int lm = 0; lm <= minus && lm <= Math.min(opCount[left], M); lm++) {

                    for (int i = 0; i < 2; i++) {

                        for (int i1 = 0; i1 < 2; i1++) {
                            if (minus - lm <= opCount[right])
                                dp[u][minus][0] = Math.max(dp[left][lm][i] + dp[right][minus - lm][i1], dp[u][minus][0]);
                            if (minus - lm - 1 >= 0 && minus - lm - 1 <= opCount[right]) {
                                dp[u][minus][0] = Math.max(dp[left][lm][i] - dp[right][minus - lm - 1][i1], dp[u][minus][0]);
                            }

                            if (minus - lm <= opCount[right])
                                dp[u][minus][1] = Math.min(dp[left][lm][i] + dp[right][minus - lm][i1], dp[u][minus][1]);
                            if (minus - lm - 1 >= 0 && minus - lm - 1 <= opCount[right])
                                dp[u][minus][1] = Math.min(dp[left][lm][i] - dp[right][minus - lm - 1][i1], dp[u][minus][1]);

                        }

                    }

                }

            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}

