#include <bits/stdc++.h>
using namespace std;
long long const INF = 2000000000;
long long const MAXN = 50001;
long long const P = 100000000000;
string str;
struct Sum {
  int coef;
  bool pre;
  Sum() : coef(1) {}
};
Sum mas[1001];
bool operator<(const Sum& a, const Sum& b) {
  if (a.coef != b.coef) return a.coef < b.coef;
  return a.pre < b.pre;
}
int main() {
  int a;
  cin >> a;
  cin >> str;
  str = "+" + str;
  int n = 0;
  for (int i = 0; i < str.size(); ++i) {
    if (str[i++] == '-') {
      mas[n].coef *= -1;
    }
    int k = 0;
    bool has = false;
    while (isdigit(str[i])) {
      k *= 10;
      k += str[i++] - '0';
      has = true;
    }
    if (k == 0 && !has) {
      mas[n].coef *= 1;
    } else {
      mas[n].coef *= k;
    }
    if (str[i] == '*') ++i;
    if (str[i] == 'a') {
      mas[n].pre = false;
    } else {
      mas[n].pre = true;
    }
    i += 2;
    ++n;
  }
  sort(mas, mas + n);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    if (mas[i].pre) ++a;
    sum += a * mas[i].coef;
    if (!mas[i].pre) ++a;
  }
  cout << sum << endl;
  return 0;
}
