#include <bits/stdc++.h>
using namespace std;
int movX[4] = {0, 1, 0, -1};
int movY[4] = {1, 0, -1, 0};
long long int mod[300010];
vector<pair<int, int> > sumandos;
int main() {
  long long int a;
  cin >> a;
  scanf(" ");
  char c;
  int valor, atras;
  int factor = 1;
  while (1) {
    scanf(" ");
    c = cin.peek();
    if (cin.eof()) break;
    if (isdigit(c)) {
      scanf("%d", &valor);
      c = getchar();
    } else {
      valor = 1;
    }
    for (long long int i = (long long int)(0); i < (long long int)(3); i++)
      c = getchar();
    (c == 'a') ? atras = 1 : atras = 0;
    sumandos.push_back(make_pair(valor * factor, atras));
    c = cin.peek();
    if (c == '+' || c == '-') {
      c = getchar();
      if (c == '+')
        factor = 1;
      else
        factor = -1;
    }
  }
  sort((sumandos).begin(), (sumandos).end());
  long long int len = sumandos.size();
  long long int rpta = 0;
  for (long long int i = (long long int)(0); i < (long long int)(len); i++) {
    if (sumandos[i].second) {
      a++;
      rpta += sumandos[i].first * a;
    } else {
      rpta += sumandos[i].first * a;
      a++;
    }
  }
  cout << rpta << endl;
  return 0;
}
