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. 
/*
Keep solving problems.
*/

import java.util.*;
import java.io.*;

public class CFA {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    private static final int MOD = 1000 * 1000 * 1000 + 7;
    private static final int[] dx = {0, -1, 0, 1};
    private static final int[] dy = {1, 0, -1, 0};
    private static final String yes = "YES";
    private static final String no = "NO";

    class Node {
        char c;
        boolean isLeaf;
        Node left;
        Node right;
        int sz;
        int[] min;
        int[] max;
        public Node(char c) {
            this.c = c;
            this.isLeaf = c != '?';
            this.sz = 0;
            min = new int[limit];
            max = new int[limit];
            Arrays.fill(min, MOD);
            Arrays.fill(max, -MOD);
        }

        @Override
        public String toString() {
            return c + " " + isLeaf + " " + sz;
        }
    }

    Node root;
    int limit = 110;
    void solve() throws IOException {
        String exp = nextString();
        int p = nextInt();
        int m = nextInt();

        List<Character> ls = getPostfix(exp);
        root = buildTree(ls);
        dfs(root);

        if (p <= m) {
            rec0(root);
            outln(root.max[p]);
        }
        else {
            rec1(root);
            outln(root.max[m]);
        }
    }

    void rec0(Node cur) {
        if (cur.isLeaf) {
            cur.max[0] = cur.c - '0';
            cur.min[0] = cur.c - '0';
            return;
        }

        rec0(cur.left);
        rec0(cur.right);
        for (int i = 0; i < limit; i++) {
            for (int j = 0; j < limit; j++) {
                if (i + j + 1 < limit) {
                    int v1 = cur.left.max[i];
                    int v2 = cur.right.max[j];
                    if (v1 != -MOD && v2 != -MOD) {
                        cur.max[i + j + 1] = Math.max(cur.max[i + j + 1], v1 + v2);
                    }

                    v1 = cur.left.min[i];
                    v2 = cur.right.min[j];
                    if (v1 != MOD && v2 != MOD) {
                        cur.min[i + j + 1] = Math.min(cur.min[i + j + 1], v1 + v2);
                    }
                }

                if (i + j < limit) {

                    int v1 = cur.left.max[i];
                    int v2 = cur.right.min[j];
                    if (v1 != -MOD && v2 != MOD) {
                        cur.max[i + j] = Math.max(cur.max[i + j], v1 - v2);
                    }

                    v1 = cur.left.min[i];
                    v2 = cur.right.max[j];
                    if (v1 != MOD && v2 != -MOD) {
                        cur.min[i + j] = Math.min(cur.min[i + j], v1 - v2);
                    }
                }
            }
        }
    }

    void rec1(Node cur) {
        if (cur.isLeaf) {
            cur.max[0] = cur.c - '0';
            cur.min[0] = cur.c - '0';
            return;
        }

        rec1(cur.left);
        rec1(cur.right);
        for (int i = 0; i < limit; i++) {
            for (int j = 0; j < limit; j++) {
                if (i + j < limit) {
                    int v1 = cur.left.max[i];
                    int v2 = cur.right.max[j];
                    if (v1 != -MOD && v2 != -MOD) {
                        cur.max[i + j] = Math.max(cur.max[i + j], v1 + v2);
                    }

                    v1 = cur.left.min[i];
                    v2 = cur.right.min[j];
                    if (v1 != MOD && v2 != MOD) {
                        cur.min[i + j] = Math.min(cur.min[i + j], v1 + v2);
                    }
                }

                if (i + j + 1 < limit) {
                    int v1 = cur.left.max[i];
                    int v2 = cur.right.min[j];
                    if (v1 != -MOD && v2 != MOD) {
                        cur.max[i + j + 1] = Math.max(cur.max[i + j + 1], v1 - v2);
                    }

                    v1 = cur.left.min[i];
                    v2 = cur.right.max[j];
                    if (v1 != MOD && v2 != -MOD) {
                        cur.min[i + j + 1] = Math.min(cur.min[i + j + 1], v1 - v2);
                    }
                }
            }
        }
    }

    void dfs(Node cur) {
        if (cur.isLeaf) {
            return;
        }
        cur.sz += 1;
        dfs(cur.left);
        dfs(cur.right);
        cur.sz += cur.left.sz;
        cur.sz += cur.right.sz;
    }

    Node buildTree(List<Character> ls) {
        Stack<Node> stack = new Stack<>();
        for (int i = 0; i < ls.size(); i++) {
            char c = ls.get(i);
            if (c == '?') {
                Node second = stack.pop();
                Node first = stack.pop();
                Node cur = new Node(c);
                cur.left = first;
                cur.right = second;
                stack.push(cur);
            }
            else {
                stack.push(new Node(c));
            }
        }

        return stack.pop();
    }

    List<Character> getPostfix(String s) {
        List<Character> res = new ArrayList<>();
        Stack<Character> stack = new Stack<>();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == '(') {
                stack.push(c);
            }
            else if (c == ')') {
                while (!stack.isEmpty()) {
                    char top = stack.pop();
                    if (top != '(') {
                        res.add(top);
                    }
                    else {
                        break;
                    }
                }
            }
            else if (c == '?') {
                stack.push(c);
            }
            else {
                res.add(c);
            }
        }

        while (!stack.isEmpty()) {
            res.add(stack.pop());
        }

        return res;
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }

    int gcd(int a, int b) {
        while(a != 0 && b != 0) {
            int c = b;
            b = a % b;
            a = c;
        }
        return a + b;
    }

    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    public CFA() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new CFA();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}

