#include <bits/stdc++.h>
using namespace std;
int toInt(string s) {
  int a = 0;
  for (int i = 0; i < (s).size(); i++) {
    a = 10 * a + (int)(s[i] - '0');
  }
  return a;
}
int signm(int a) {
  if (a < 0)
    return -1;
  else
    return 1;
}
int main() {
  int a;
  cin >> a;
  string s;
  cin >> s;
  s += "-";
  vector<string> sums;
  vector<int> signs;
  string cur = "";
  int done = 0, sgn = 1;
  for (int i = 0; i < (s).size(); i++) {
    if ((s[i] == '+') || (s[i] == '-')) {
      if (done == 2) {
        sums.push_back(cur);
        signs.push_back(sgn);
        cur = "";
        if (s[i] == '+') {
          sgn = 1;
        } else {
          sgn = -1;
        }
        done = 0;
      } else {
        cur += s[i];
        done++;
      }
    } else {
      cur += s[i];
    }
  }
  vector<int> coef((sums).size());
  vector<bool> bef((sums).size());
  for (int i = 0; i < (sums).size(); i++) {
    if (isdigit(sums[i][0])) {
      string z;
      int j = 0;
      while (isdigit(sums[i][j])) {
        z += sums[i][j];
        j++;
      }
      coef[i] = toInt(z);
    } else {
      coef[i] = 1;
    }
    bef[i] = (sums[i][(sums[i]).size() - 1] == 'a');
  }
  for (int i = 0; i < (coef).size(); i++) {
    coef[i] *= signs[i];
  }
  vector<pair<int, pair<int, int> > > w((coef).size());
  for (int i = 0; i < (w).size(); i++) {
    w[i] = make_pair(
        coef[i], make_pair((bef[i] ? -1 * signm(coef[i]) : 1 * signm(coef[i])),
                           (bef[i] ? -1 : 1)));
  }
  sort((w).begin(), (w).end());
  int ans = 0;
  for (int i = 0; i < (w).size(); i++) {
    if (w[i].second.second == -1) {
      ++a;
      ans += a * w[i].first;
    } else {
      ans += a * w[i].first;
      ++a;
    }
  }
  cout << ans << "\n";
  return 0;
}
