#include <bits/stdc++.h>
using namespace std;
const int N = 1000;
int inc[N];
int coef[N];
int sign[N];
int tek;
char c;
bool number(char c) { return c >= '0' && c <= '9'; }
void get_coefficient() {
  scanf(" %c", &c);
  if (!number(c)) {
    coef[tek] = 1;
    return;
  };
  coef[tek] = 0;
  while (c != '*') {
    coef[tek] = coef[tek] * 10 + c - '0';
    scanf(" %c", &c);
  }
  scanf(" %c", &c);
}
void get_summand() {
  get_coefficient();
  if (c == '+') {
    char c1, c2;
    scanf(" %c %c", &c1, &c2);
    assert(c1 == '+' && c2 == 'a');
    inc[tek] = -1;
  } else {
    char c1, c2;
    scanf(" %c %c", &c1, &c2);
    assert(c1 == '+' && c2 == '+');
    inc[tek] = 1;
  }
}
bool get_expression() {
  get_summand();
  char c;
  if (scanf("%c", &c) != 1 || c == '\n') {
    tek++;
    return false;
  }
  sign[++tek] = c == '+' ? 1 : -1;
  return true;
}
struct sl {
  int c, t;
  sl() {}
  sl(int i) {
    c = sign[i] * coef[i];
    t = inc[i];
  }
};
sl op[N];
bool operator<(sl a, sl b) {
  if (a.c != b.c) return a.c < b.c;
  return a.t * a.c < b.t * b.c;
}
int main() {
  int a;
  scanf("%d ", &a);
  tek = 0;
  sign[0] = 1;
  while (get_expression())
    ;
  for (int i = 0; i < tek; i++) {
    op[i] = sl(i);
  }
  sort(op, op + tek);
  int sum = 0;
  for (int i = 0; i < tek; i++) {
    if (op[i].t == -1) a++;
    sum += op[i].c * a;
    if (op[i].t == 1) a++;
  }
  printf("%d\n", sum);
  return 0;
}
