#include <bits/stdc++.h>
using namespace std;
const int maxn = 10005;
int v[maxn], n, m, ans;
int main() {
  string s;
  int i, t, p;
  cin >> m >> s;
  if (s[0] != '-') s = "+" + s;
  for (i = 0; i < s.length(); i += 3) {
    p = s[i++] == '+' ? 1 : -1;
    for (t = 0; s[i] >= '0' && s[i] <= '9'; ++i) t = t * 10 + s[i] - '0';
    if (s[i] == '*')
      ++i;
    else
      t = 1;
    t *= p;
    v[++n] = t;
    ans += (m - (s[i] == 'a')) * t;
  }
  sort(v + 1, v + n + 1);
  for (i = 1; i <= n; ++i) ans += i * v[i];
  cout << ans << endl;
  return 0;
}
