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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;

import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.Math.max;
import static java.lang.Math.min;

public class ProblemE3 {
    private static final long INF = MAX_VALUE / 3;
    BufferedReader rd;

    ProblemE3() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        String s = rd.readLine();
        int[] pm = intarr();
        int p = pm[0];
        int m = pm[1];

        out(solve(s,p,m));
    }

    private long solve(String s, int p, int m) {
        Node root = solve(s);
        if(p < m) {
            return root.d[0][p][1];
        } else {
            return root.d[1][m][1];
        }
    }

    private Node solve(String s) {
        Node root = constructNode(s.toCharArray());
        Deque<Node> stack = new ArrayDeque<>();
        stack.push(root);
        while(!stack.isEmpty()) {
            Node node = stack.peek();
            if(node.left != null) {
                if(!node.left.processed) {
                    stack.push(node.left);
                } else if(node.right != null) {
                    if(!node.right.processed) {
                        stack.push(node.right);
                    } else {
                        stack.pop();
                        node.merge();
                        node.processed = true;
                    }
                } else {
                    throw new RuntimeException("right=null");
                }
            } else {
                node.processed = true;
                stack.pop();
            }
        }
        return root;
    }

    private Node constructNode(char[] s) {
        Deque<Node[]> stack = new ArrayDeque<>();
        Node root = new Node();
        Node left = null;
        for(char c: s) {
            if(c == '(') {
                stack.push(new Node[] { root, left });
                root = new Node();
            } else if(c == ')') {
                Node[] upper = stack.pop();
                upper[0].left = left;
                upper[0].right = root;
                root = upper[0];
                left = upper[1];
            } else if(c == '?') {
                left = root;
                root = new Node();
            } else {
                root.set(c-'0');
            }
        }
        return root;
    }

    private static final int LIM = 111;

    class Node {
        boolean processed;
        Node left;
        Node right;
        // plus/minus, count, mi/ma
        long[][][] d = new long[2][LIM+1][2];

        void set(long x) {
            d[0][0][0] = x;
            d[0][0][1] = x;
            d[1][0][0] = x;
            d[1][0][1] = x;
        }

        Node() {
            for(int i=0;i<2;i++) {
                for(int j=0;j<=LIM;j++) {
                    d[i][j][0] = INF;
                    d[i][j][1] = -INF;
                }
            }
        }

        public void merge() {
            if(left != null && right != null) {
                for (int z = 0; z < 2; z++) {
                    for (int i = 0; i < LIM; i++) {
                        for (int j = 0; j < LIM; j++) {
                            for (int u = 0; u < 2; u++) {
                                for (int v = 0; v < 2; v++) {
                                    int k = i + j + 1;
                                    if (k <= LIM) {
                                        if (ltInf(left.d[z][i][u]) && ltInf(right.d[z][j][v])) {
                                            relax(z, k, left.d[z][i][u] + (1 - z * 2) * right.d[z][j][v]);
                                        }
                                    }
                                    k = i + j;
                                    if (k <= LIM) {
                                        if (ltInf(left.d[z][i][u]) && ltInf(right.d[z][j][v])) {
                                            relax(z, k, left.d[z][i][u] + (z * 2 - 1) * right.d[z][j][v]);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            } else {
                throw new RuntimeException("left/right null vs. non-null, left="+left+", right="+right);
            }
        }

        private boolean ltInf(long x) {
            return abs(x) < INF;
        }

        private void relax(int plusMinus, int plusMinusCount, long value) {
            d[plusMinus][plusMinusCount][0] = min(d[plusMinus][plusMinusCount][0], value);
            d[plusMinus][plusMinusCount][1] = max(d[plusMinus][plusMinusCount][1], value);
        }

        @Override
        public String toString() {
            if(left == null) {
                return Arrays.deepToString(d);
            }
            return "("+left+":"+Arrays.deepToString(d)+":"+right+")";
        }
    }

    private int[] intarr() throws IOException {
        return intarr(rd.readLine());
    }

    private int[] intarr(String s) {
        String[] q = split(s);
        int n = q.length;
        int[] a = new int[n];
        for(int i=0;i<n;i++) {
            a[i] = Integer.parseInt(q[i]);
        }
        return a;
    }

    private String[] split(String s) {
        if(s == null) {
            return new String[0];
        }
        int n = s.length();
        int start = -1;
        int end = 0;
        int sp = 0;
        boolean lastWhitespace = true;
        for(int i=0;i<n;i++) {
            char c = s.charAt(i);
            if(isWhitespace(c)) {
                lastWhitespace = true;
            } else {
                if(lastWhitespace) {
                    sp++;
                }
                if(start == -1) {
                    start = i;
                }
                end = i;
                lastWhitespace = false;
            }
        }
        if(start == -1) {
            return new String[0];
        }
        String[] res = new String[sp];
        int last = start;
        int x = 0;
        lastWhitespace = true;
        for(int i=start;i<=end;i++) {
            char c = s.charAt(i);
            boolean w = isWhitespace(c);
            if(w && !lastWhitespace) {
                res[x++] = s.substring(last,i);
            } else if(!w && lastWhitespace) {
                last = i;
            }
            lastWhitespace = w;
        }
        res[x] = s.substring(last,end+1);
        return res;
    }

    private boolean isWhitespace(char c) {
        return c==' ' || c=='\t';
    }

    private static void out(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args) throws IOException {
        new ProblemE3();
    }
}
