#include <bits/stdc++.h>
using namespace std;
const int maxn = 1234 + 10;
int cnt = 0;
int now = 1;
struct node {
  int xi;
  int flag;
  bool friend operator<(node a, node b) { return a.xi < b.xi; }
} a[maxn];
void f() {
  int pre = -1;
  char c;
  int xi = 0;
  c = getchar();
  if (c == 'a') {
    xi = 1;
    pre = 1;
    c = getchar();
    c = getchar();
  } else if (c == '+') {
    xi = 1;
    pre = 0;
    c = getchar();
    c = getchar();
  } else {
    xi = c - '0';
    while (c = getchar()) {
      if (c >= '0' && c <= '9')
        xi = xi * 10 + c - '0';
      else {
        break;
      }
    }
    c = getchar();
    if (c == 'a') {
      pre = 1;
      c = getchar();
      c = getchar();
    } else if (c == '+') {
      pre = 0;
      c = getchar();
      c = getchar();
    }
  }
  if (now)
    a[++cnt].xi = xi;
  else
    a[++cnt].xi = -xi;
  a[cnt].flag = pre;
}
int main() {
  int n;
  scanf("%d", &n);
  getchar();
  char c;
  while (1) {
    f();
    if (c = getchar()) {
      if (c == '\n') {
        break;
      } else if (c == '+') {
        now = 1;
      } else {
        now = 0;
      }
    }
  }
  sort(a + 1, a + 1 + cnt);
  int ans = 0;
  for (int i = 1; i <= cnt; i++) {
    if (a[i].flag == 1) {
      ans += a[i].xi * n;
      n++;
    } else {
      n++;
      ans += a[i].xi * n;
    }
  }
  printf("%d\n", ans);
  return 0;
}
