#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main() {
  int a, n, i = 0, sgn = 1, c = 1;
  long long ans = 0;
  string s;
  cin >> a >> s;
  n = s.length();
  while (i < n) {
    sgn = 1, c = 0;
    if (i) {
      sgn = (s[i] == '+') ? 1 : -1;
      i++;
    }
    if (s[i] >= '0' && s[i] <= '9') {
      while (s[i] >= '0' && s[i] <= '9') c = c * 10 + (s[i] - '0'), i++;
    } else
      c = 1;
    v.push_back(c * sgn);
    if (s[i] == '*') i++;
    if (s[i] != 'a') ans += c * sgn;
    i += 3;
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); i++) ans += a * v[i], a++;
  cout << ans << endl;
  return 0;
}
