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. 
#include <bits/stdc++.h>
const int inf = 0x3f3f3f3f, Inf = 0x7fffffff;
const long long INF = 0x7fffffffffffffff;
const double eps = 1e-10;
unsigned int seed = 19260817;
const unsigned int _RAND_MAX_ = 4294967295u;
__inline__ __attribute__((always_inline)) unsigned int Rand() {
  return seed = seed * 998244353u + 1000000007u;
}
template <typename _Tp>
_Tp gcd(const _Tp &a, const _Tp &b) {
  return (!b) ? a : gcd(b, a % b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp abs(const _Tp &a) {
  return a > 0 ? a : -a;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp max(const _Tp &a, const _Tp &b) {
  return a < b ? b : a;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp min(const _Tp &a, const _Tp &b) {
  return a < b ? a : b;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void chmax(_Tp &a, const _Tp &b) {
  (a < b) && (a = b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void chmin(_Tp &a, const _Tp &b) {
  (a > b) && (a = b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) bool _cmp(const _Tp &a,
                                                    const _Tp &b) {
  return abs(a - b) <= eps;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void read(_Tp &x) {
  register char ch(getchar());
  bool f(false);
  while (ch < 48 || ch > 57) f |= ch == 45, ch = getchar();
  x = ch & 15, ch = getchar();
  while (ch >= 48 && ch <= 57)
    x = (((x << 2) + x) << 1) + (ch & 15), ch = getchar();
  if (f) x = -x;
}
template <typename _Tp, typename... Args>
__inline__ __attribute__((always_inline)) void read(_Tp &t, Args &...args) {
  read(t);
  read(args...);
}
__inline__ __attribute__((always_inline)) int read_str(char *s) {
  register char ch(getchar());
  while (ch == ' ' || ch == '\r' || ch == '\n') ch = getchar();
  register char *tar = s;
  *tar = ch, ch = getchar();
  while (ch != ' ' && ch != '\r' && ch != '\n' && ch != EOF)
    *(++tar) = ch, ch = getchar();
  return tar - s + 1;
}
const int N = 10005;
char s[N];
int node_cnt;
int st[N];
int ls[N], rs[N];
int a[N];
int build() {
  int n = read_str(s + 1);
  int top = 0;
  for (int i = 1; i <= n; ++i) {
    if (s[i] == '(') {
      st[++top] = -1;
    } else if (s[i] == '?') {
      continue;
    } else if (s[i] == ')') {
      int t1 = st[top], t2 = st[top - 1];
      top -= 3;
      int cur = ++node_cnt;
      ls[cur] = t2, rs[cur] = t1;
      st[++top] = cur;
    } else {
      st[++top] = ++node_cnt;
      a[node_cnt] = s[i] - 48;
    }
  }
  if (top != 1) exit(233);
  return st[top];
}
int A, B;
int f[N][105], g[N][105];
int dfs1(int x) {
  if (!ls[x]) {
    f[x][0] = a[x];
    g[x][0] = a[x];
    return 0;
  }
  int siz = 1;
  int siz1, siz2;
  siz += siz1 = dfs1(ls[x]);
  siz += siz2 = dfs1(rs[x]);
  for (int i = 0; i <= A && i <= siz; ++i) {
    for (int j = 0; j <= i && j <= siz1; ++j) {
      if (i - j <= siz2) {
        chmax(f[x][i], f[ls[x]][j] - g[rs[x]][i - j]);
        chmin(g[x][i], g[ls[x]][j] - f[rs[x]][i - j]);
      }
    }
    for (int j = 0; j < i && j <= siz1; ++j) {
      if (i - j - 1 <= siz2) {
        chmax(f[x][i], f[ls[x]][j] + f[rs[x]][i - j - 1]);
        chmin(g[x][i], g[ls[x]][j] + g[rs[x]][i - j - 1]);
      }
    }
  }
  return siz;
}
int dfs2(int x) {
  if (!ls[x]) {
    f[x][0] = a[x];
    g[x][0] = a[x];
    return 0;
  }
  int siz = 1;
  int siz1, siz2;
  siz += siz1 = dfs2(ls[x]);
  siz += siz2 = dfs2(rs[x]);
  for (int i = 0; i <= B; ++i) {
    for (int j = 0; j <= i && j <= siz1; ++j) {
      if (i - j <= siz2) {
        chmax(f[x][i], f[ls[x]][j] + f[rs[x]][i - j]);
        chmin(g[x][i], g[ls[x]][j] + g[rs[x]][i - j]);
      }
    }
    for (int j = 0; j < i && j <= siz1; ++j) {
      if (i - j - 1 <= siz2) {
        chmax(f[x][i], f[ls[x]][j] - g[rs[x]][i - j - 1]);
        chmin(g[x][i], g[ls[x]][j] - f[rs[x]][i - j - 1]);
      }
    }
  }
  return siz;
}
int main() {
  memset(g, 63, sizeof(g));
  memset(f, -63, sizeof(f));
  int root = build();
  read(A, B);
  if (A <= 100) {
    dfs1(root);
    printf("%d\n", f[root][A]);
  } else {
    dfs2(root);
    printf("%d\n", f[root][B]);
  }
  return 0;
}
