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 E {

    static final int MIN = 0;
    static final int MAX = 1;

    char[] e;
    int p, m;
    int sign;

    int pos;

    int[][] calc() {
        int[][] res = new int[2][p + 1];
        Arrays.fill(res[MIN], Integer.MAX_VALUE);
        Arrays.fill(res[MAX], Integer.MIN_VALUE);
        if (e[pos] == '(') {
            ++pos;
            int[][] left = calc();
            ++pos;
            int[][] right = calc();
            ++pos;
            for (int a = MIN; a <= MAX; ++a) {
                for (int b = MIN; b <= MAX; ++b) {
                    for (int i = 0; i <= p && left[a][i] > Integer.MIN_VALUE && left[a][i] < Integer.MAX_VALUE; ++i) {
                        for (int j = 0; j <= p - i && right[b][j] > Integer.MIN_VALUE && right[b][j] < Integer.MAX_VALUE; ++j) {
                            res[MIN][i + j] = Math.min(res[MIN][i + j], left[a][i] - sign * right[b][j]);
                            res[MAX][i + j] = Math.max(res[MAX][i + j], left[a][i] - sign * right[b][j]);
                            if (i + j < p) {
                                res[MIN][i + j + 1] = Math.min(res[MIN][i + j + 1], left[a][i] + sign * right[b][j]);
                                res[MAX][i + j + 1] = Math.max(res[MAX][i + j + 1], left[a][i] + sign * right[b][j]);
                            }
                        }
                    }
                }
            }
        } else {
            res[MIN][0] = res[MAX][0] = e[pos] - '0';
            ++pos;
        }
        return res;
    }

    void solve() throws IOException {
        in = new InputReader("__std");
        out = new OutputWriter("__std");

        e = in.readToken().toCharArray();
        p = in.readInt();
        m = in.readInt();
        sign = 1;
        if (p > m) {
            int t = p; p = m; m = t;
            sign = -1;
        }
        out.println(calc()[MAX][p]);

        exit();
    }

    void exit() {
        out.close();
        //System.err.println((System.currentTimeMillis() - startTime) + " ms");
        System.exit(0);
    }

    InputReader in;
    OutputWriter out;

    //long startTime = System.currentTimeMillis();

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

    class InputReader {

        private InputStream stream;

        private byte[] buffer = new byte[1024];
        private int pos, len;

        private int cur;

        private StringBuilder sb = new StringBuilder(32);

        InputReader(String name) throws IOException {
            if (name.equals("__std")) {
                stream = System.in;
            } else {
                stream = new FileInputStream(name);
            }
            cur = read();
        }

        private int read() throws IOException {
            if (len == -1) {
                throw new EOFException();
            }
            if (pos >= len) {
                pos = 0;
                len = stream.read(buffer);
                if (len == -1) return -1;
            }
            return buffer[pos++] & 0xff;
        }

        boolean whitespace() {
            return cur == ' ' || cur == '\t' || cur == '\r' || cur == '\n' || cur == -1;
        }

        boolean eol() {
            return cur == '\r' || cur == '\n' || cur == -1;
        }

        boolean eof() {
            return cur == -1;
        }

        byte readByte() throws IOException {
            if (eof()) {
                throw new EOFException();
            }
            byte res = (byte) cur;
            cur = read();
            return res;
        }

        char readChar() throws IOException {
            if (eof()) {
                throw new EOFException();
            }
            char res = (char) cur;
            cur = read();
            return res;
        }

        int readInt() throws IOException {
            if (eof()) {
                throw new EOFException();
            }
            while (whitespace()) {
                cur = read();
            }
            if (eof()) {
                throw new EOFException();
            }
            int sign = 1;
            if (cur == '-') {
                sign = -1;
                cur = read();
                if (cur < '0' || cur > '9') {
                    throw new NumberFormatException();
                }
            }
            int res = 0;
            while (!whitespace()) {
                if (cur < '0' || cur > '9') {
                    throw new NumberFormatException();
                }
                res *= 10;
                res += cur - '0';
                cur = read();
            }
            return res * sign;
        }

        long readLong() throws IOException {
            if (eof()) {
                throw new EOFException();
            }
            while (whitespace()) {
                cur = read();
            }
            if (eof()) {
                throw new EOFException();
            }
            int sign = 1;
            if (cur == '-') {
                sign = -1;
                cur = read();
                if (cur < '0' || cur > '9') {
                    throw new NumberFormatException();
                }
            }
            long res = 0;
            while (!whitespace()) {
                if (cur < '0' || cur > '9') {
                    throw new NumberFormatException();
                }
                res *= 10;
                res += cur - '0';
                cur = read();
            }
            return res * sign;
        }

        double readDouble() throws IOException {
            return Double.parseDouble(readToken());
        }

        String readToken() throws IOException {
            if (eof()) {
                throw new EOFException();
            }
            while (whitespace()) {
                cur = read();
            }
            if (eof()) {
                throw new EOFException();
            }
            sb.setLength(0);
            while (!whitespace()) {
                sb.append((char) cur);
                cur = read();
            }
            return sb.toString();
        }

        String readLine() throws IOException {
            if (eof()) {
                throw new EOFException();
            }
            sb.setLength(0);
            while (!eol()) {
                sb.append((char) cur);
                cur = read();
            }
            if (cur == '\r') {
                cur = read();
            }
            if (cur == '\n') {
                cur = read();
            }
            return sb.toString();
        }
    }

    class OutputWriter {

        private PrintWriter writer;

        OutputWriter(String name) throws IOException {
            if (name.equals("__std")) {
                writer = new PrintWriter(System.out);
            } else {
                writer = new PrintWriter(name);
            }
        }

        void print(String format, Object ... args) {
            writer.print(new Formatter(Locale.US).format(format, args));
        }

        void println(String format, Object ... args) {
            writer.println(new Formatter(Locale.US).format(format, args));
        }

        void print(Object value) {
            writer.print(value);
        }

        void println(Object value) {
            writer.println(value);
        }

        void println() {
            writer.println();
        }

        void printArray(int[] a) {
            boolean first = true;
            for (int v : a) {
                if (!first) {
                    writer.print(' ');
                } else {
                    first = false;
                }
                writer.print(v);
            }
            writer.println();
        }

        void printArray(int[][] a) {
            for (int[] v : a) {
                printArray(v);
            }
        }

        void flush() {
            writer.flush();
        }

        void close() {
            writer.close();
        }
    }
}
