#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > expr;
int readCoeff() {
  char znak = '+';
  if (expr.size() != 0 && (cin.peek() == '+' || cin.peek() == '-'))
    scanf("%c", &znak);
  int coeff = 1;
  if ('0' <= cin.peek() && cin.peek() <= '9') scanf("%d*", &coeff);
  return coeff * (znak == '-' ? -1 : 1);
}
int inc() {
  if (cin.peek() == '+') {
    scanf("++a");
    return 1;
  } else {
    scanf("a++");
    return 0;
  }
}
int main() {
  int a;
  scanf("%d%*c", &a);
  while (cin.peek() == 'a' || cin.peek() == '+' || cin.peek() == '-' ||
         '0' <= cin.peek() && cin.peek() <= '9') {
    int f = readCoeff(), s = inc();
    expr.push_back(make_pair(f, s));
  }
  sort(expr.begin(), expr.end());
  int ans = 0;
  for (vector<pair<int, int> >::iterator(i) = (expr).begin();
       (i) < (expr).end(); ++(i)) {
    if (i->second == 1) {
      ++a;
      ans += a * (i->first);
    } else {
      ans += a * (i->first);
      a++;
    }
  }
  cout << ans;
  return 0;
}
