#include <bits/stdc++.h>
using namespace std;
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
char s[100007];
vector<pair<int, int> > negative, positive;
int main() {
  int a;
  scanf("%d", &a);
  scanf("%s", s);
  bool plus = true;
  for (int i = 0, num = 1; s[i];) {
    ;
    if (isdigit(s[i])) {
      num = 0;
      while (s[i] && isdigit(s[i])) {
        num = num * 10 + s[i] - '0';
        i++;
      }
    } else if (s[i] == '+') {
      if (s[i + 1] == '+' && s[i + 2] == 'a') {
        if (plus)
          positive.push_back({num, 0});
        else
          negative.push_back({num, 0});
        i += 3;
        num = 1;
      } else {
        plus = true;
        i++;
      }
    } else if (s[i] == '-') {
      plus = false;
      i++;
    } else if (s[i] == 'a') {
      if (plus)
        positive.push_back({num, 1});
      else
        negative.push_back({num, 1});
      i += 3;
      num = 1;
    } else
      i++;
  }
  sort(positive.begin(), positive.end());
  sort(negative.begin(), negative.end());
  reverse(negative.begin(), negative.end());
  ;
  long long sum = 0;
  for (int i = 0; i < negative.size(); i++) {
    if (negative[i].second == 0) ++a;
    sum -= negative[i].first * a;
    if (negative[i].second) a++;
    ;
  }
  for (int i = 0; i < positive.size(); i++) {
    if (positive[i].second == 0) ++a;
    sum += positive[i].first * a;
    if (positive[i].second) a++;
    ;
  }
  printf("%lld\n", sum);
  return 0;
}
