#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const double eps = 1e-6;
struct pp {
  int k, pre;
  bool operator<(const pp& t) const { return k < t.k; }
};
int main() {
  int init;
  cin >> init;
  string s;
  cin >> s;
  multiset<pp> all;
  int k = 0;
  bool nextsign = false;
  for (; k < s.size();) {
    bool sign = nextsign;
    int coef = 1;
    int pre = 0;
    if (isdigit(s[k])) {
      int z = 0;
      for (; k < s.size() && isdigit(s[k]); k++) {
        z = z * 10 + s[k] - '0';
      }
      coef = z;
      if (k < s.size() && s[k] == '*') k++;
    }
    if (s[k] == '+' && s[k + 1] == '+' && s[k + 2] == 'a') {
      pre = 1;
    } else if (s[k] == 'a' && s[k + 1] == '+' && s[k + 2] == '+') {
      pre = 0;
    } else
      return -1;
    if (sign) coef = -coef;
    pp p;
    p.k = coef;
    p.pre = pre;
    all.insert(p);
    k += 3;
    if (k < s.size()) {
      nextsign = (s[k++] == '-');
    }
  }
  long long res = 0;
  for (; all.size(); all.erase(all.begin())) {
    int q = all.begin()->k;
    int w = all.begin()->pre;
    if (w) {
      init++;
      res += q * init;
    } else {
      res += q * init;
      init++;
    }
  }
  cout << res << endl;
  return 0;
}
