#include <bits/stdc++.h>
using namespace std;
string str;
int num[100005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int a, n = 0, ans = 0;
  cin >> a >> str;
  if (str[0] != '-') str = "+" + str;
  for (int i = 0; i < str.size(); i += 3) {
    int k = str[i++] == '+' ? 1 : -1, x = 0;
    for (; str[i] >= '0' && str[i] <= '9'; i++) x = x * 10 + str[i] - '0';
    if (str[i] == '*')
      i++;
    else
      x = 1;
    x *= k;
    num[n++] = x;
    ans += (a - (str[i] == 'a')) * x;
  }
  sort(num, num + n);
  for (int i = 0; i < n; i++) ans += (i + 1) * num[i];
  cout << ans << endl;
  return 0;
}
