#include <bits/stdc++.h>
using namespace std;
const int MAXN = 102030;
char s[MAXN];
int n, ori, len, ans;
struct crl {
  int num, pre;
  bool operator<(const crl &c) const { return num < c.num; }
} arr[MAXN];
int main() {
  for (int i = 1; i <= 100000; i++) arr[i].num = -1;
  scanf("%d", &ori), scanf("%s", s + 1), len = strlen(s + 1), s[0] = '+';
  for (int i = 1, las = 0; i <= len; i++)
    if (s[i] == 'a') {
      n++;
      for (int j = las + 1; j < i; j++)
        if (s[j] >= '0' && s[j] <= '9')
          arr[n].num = (arr[n].num == -1 ? 0 : arr[n].num * 10) + s[j] - '0';
        else
          break;
      if (arr[n].num == -1) arr[n].num = 1;
      arr[n].num *= (s[las] == '+' ? 1 : -1),
          las = i + 3 -
                2 * (arr[n].pre = s[i - 1] == s[i - 2] && s[i - 2] == '+' &&
                                  i - 2 > las);
    }
  sort(arr + 1, arr + 1 + n);
  for (int i = 1; i <= n; i++)
    if (arr[i].pre)
      ans += ++ori * arr[i].num;
    else
      ans += ori++ * arr[i].num;
  printf("%d\n", ans);
}
