#include <bits/stdc++.h>
using namespace std;
string s;
struct SUM {
  int n;
  bool pp;
} b;
vector<SUM> a;
bool cmp(SUM u, SUM v) { return u.n < v.n; }
int main() {
  std::ios::sync_with_stdio(false);
  int i, j, k, m;
  cin >> m >> s;
  s = s[0] == '-' ? s : "+" + s;
  for (i = 0; i < s.size();) {
    j = i + 1;
    if (s[i + 1] < '0' || s[i + 1] > '9')
      k = 1;
    else {
      for (k = 0; s[j] >= '0' && s[j] <= '9'; ++j) k = k * 10 + s[j] - '0';
      ++j;
    }
    if (s[i] == '-') k = -k;
    b.n = k;
    b.pp = s[j] != 'a';
    a.push_back(b);
    i = j + 3;
  }
  sort(a.begin(), a.end(), cmp);
  for (k = 0, i = 0; i < a.size(); ++i) {
    if (a[i].pp)
      k += a[i].n * ++m;
    else
      k += a[i].n * m++;
  }
  cout << k << endl;
  return 0;
}
