#include <bits/stdc++.h>
using namespace std;
int c[1005];
int o[1005];
int op[1005];
int v[1005], n;
char s[1000005];
int x;
bool parse() {
  int ox;
  if (s[x] >= '0' && s[x] <= '9') {
    sscanf(s + x, "%d%n", &c[n], &ox);
    x += ox;
    ++x;
  } else
    c[n] = 1;
  if (s[x] == 'a') {
    o[n] = 0;
  } else {
    o[n] = 1;
  }
  x += 3;
  if (s[x] == '+') {
    op[n] = 1;
    ++x;
    n++;
  } else if (s[x] == '-') {
    op[n] = -1;
    n++;
    ++x;
  } else {
    n++;
    return false;
  }
  return true;
}
const int R = 2005;
int g[R][R];
int cap[R][R];
int S, T;
int d[R], inq[R], last[R];
int flow() {
  for (int i = 0; i <= T; i++) d[i] = -514514514, inq[i] = 0;
  d[S] = 0;
  last[S] = -1;
  queue<int> Q;
  Q.push(S);
  while (!Q.empty()) {
    int X = Q.front();
    Q.pop();
    inq[X] = 0;
    for (int i = 0; i <= T; i++) {
      if (i == S) continue;
      if (cap[X][i] && d[i] < d[X] + g[X][i]) {
        d[i] = d[X] + g[X][i];
        last[i] = X;
        if (!inq[i]) {
          Q.push(i);
          inq[i] = 1;
        }
      }
    }
  }
  if (d[T] == -514514514) return -514514514;
  int ret = d[T], it = T;
  while (last[it] >= 0) {
    cap[it][last[it]] = 1;
    cap[last[it]][it] = 0;
    it = last[it];
  }
  return ret;
}
int main(void) {
  int a;
  scanf("%d", &a);
  scanf("%s", s);
  while (parse())
    ;
  for (int i = 0; i < n - 1; i++)
    if (op[i] < 0) c[i + 1] = -c[i + 1];
  int DMIN = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      g[i][j] = c[i] * (a + j + o[i]);
      DMIN = min(DMIN, g[i][n + j]);
      cap[i][n + j] = 1;
    }
  int base = 0;
  for (int i = 0; i < n; i++) base += g[i][0];
  int pp[1005], pn = 0;
  for (int i = 0; i < n; i++) pp[pn++] = c[i];
  sort(pp, pp + pn);
  for (int i = 0; i < n; i++) base += pp[i] * i;
  printf("%d\n", base);
  return 0;
}
