#include <bits/stdc++.h>
using namespace std;
bool P;
int n, m, p;
char s[11111];
int mn[11111][111], mx[11111][111];
int dfs(int v) {
  if ('0' <= s[v] and s[v] <= '9') {
    mn[v][0] = mx[v][0] = s[v] - '0';
    return v + 1;
  }
  int c1 = v + 1, c2 = dfs(v + 1) + 1;
  int ret = dfs(c2) + 1;
  for (int i = 1; i <= 101; i++) {
    for (int j = 0; j < i; j++) {
      if (P) {
        mx[v][i] = max(mx[v][i], mx[c1][j] + mx[c2][i - j - 1]);
        mn[v][i] = min(mn[v][i], mn[c1][j] + mn[c2][i - j - 1]);
      } else {
        mx[v][i] = max(mx[v][i], mx[c1][j] - mn[c2][i - j - 1]);
        mn[v][i] = min(mn[v][i], mn[c1][j] - mx[c2][i - j - 1]);
      }
    }
  }
  for (int i = 0; i <= 101; i++) {
    for (int j = 0; j <= i; j++) {
      if (P) {
        mx[v][i] = max(mx[v][i], mx[c1][j] - mn[c2][i - j]);
        mn[v][i] = min(mn[v][i], mn[c1][j] - mx[c2][i - j]);
      } else {
        mx[v][i] = max(mx[v][i], mx[c1][j] + mx[c2][i - j]);
        mn[v][i] = min(mn[v][i], mn[c1][j] + mn[c2][i - j]);
      }
    }
  }
  return ret;
}
int main() {
  for (int i = 0; i < 11111; i++)
    for (int j = 0; j < 111; j++) mx[i][j] = -(mn[i][j] = 1e9);
  scanf("%s", s);
  scanf("%d%d", &p, &m);
  P = (p < m);
  dfs(0);
  printf("%d\n", (P ? mx[0][p] : mx[0][m]));
  return 0;
}
