#include <bits/stdc++.h>
using namespace std;
struct Data {
  int fac;
  bool increase;
  Data(int num, bool first) {
    fac = num;
    increase = first;
  }
};
vector<Data> data;
bool DataCmp(Data d1, Data d2) { return d1.fac < d2.fac; }
int a;
char s[2000];
int main() {
  scanf("%d", &a);
  long long sol = 0;
  scanf("%s", s);
  bool minus = false;
  unsigned int pos = 0;
  while (pos < strlen(s)) {
    if (pos == 0) {
      minus = false;
    } else {
      minus = (s[pos] == '-');
      pos++;
    }
    char ch[10];
    int counter = 0;
    while (s[pos + counter] <= '9' && s[pos + counter] >= '0') {
      ch[counter] = s[pos + counter];
      counter++;
    }
    ch[counter] = 0;
    int fac = 1;
    if (counter > 0) {
      fac = atoi(ch);
    }
    if (minus) {
      fac *= -1;
    }
    pos = pos + counter;
    if (counter > 0) {
      pos++;
    }
    if (s[pos] == 'a') {
      data.push_back(Data(fac, false));
    } else {
      data.push_back(Data(fac, true));
    }
    pos += 3;
  }
  sort(data.begin(), data.end(), DataCmp);
  int n = 0;
  while (n < data.size()) {
    int d[2] = {0, 0};
    d[data[n].increase]++;
    int k = n + 1;
    while (k < data.size() && data[k].fac == data[k - 1].fac) {
      d[data[k].increase]++;
      k++;
    }
    while (n < k) {
      if (data[n].fac < 0) {
        if (d[0]) {
          sol += data[n].fac * (a++);
          d[0]--;
        } else {
          sol += data[n].fac * (++a);
          d[1]--;
        }
      } else if (data[n].fac > 0) {
        if (d[1]) {
          sol += data[n].fac * (++a);
          d[1]--;
        } else {
          sol += data[n].fac * (a++);
          d[0]--;
        }
      } else {
        a++;
      }
      n++;
    }
  }
  printf("%lld\n", sol);
}
