#include <bits/stdc++.h>
using namespace std;
struct info {
  int co, ty;
} ar[10000];
bool comp(info x, info y) { return x.co < y.co; }
int fun(string s, int t) {
  int l = s.size();
  if (l == 0) return t;
  int ans = 0;
  for (int i = 0; i < l; i++) ans = ans * 10 + s[i] - 48;
  return ans * t;
}
int main() {
  string s, num;
  int a, l, t = 1, j = 0, top = -1, in = 0;
  cin >> a;
  cin >> s;
  l = s.size();
  s += '#';
  s += '#';
  for (int i = 0; i < 10000; i++) ar[i].co = 1;
  if (s[0] == '-') {
    t = -1;
    in = 1;
  }
  for (int i = 0; i < l; i++) {
    if (s[i] == '*') continue;
    if (isdigit(s[i]))
      num += s[i];
    else if (isalpha(s[i])) {
      if (top > -1) {
        ar[j].co = fun(num, t);
        ar[j].ty = 1;
        top = -1;
        j++;
        i++;
        if (s[i] == '+')
          t = 1;
        else
          t = -1;
        num = "";
      } else {
        ar[j].co = fun(num, t);
        ar[j].ty = 0;
        j++;
        i += 3;
        if (s[i] == '+')
          t = 1;
        else
          t = -1;
        num = "";
      }
    } else
      top++;
  }
  sort(ar, ar + j, comp);
  int ans = 0;
  for (int i = 0; i < j; i++) {
    if (ar[i].ty == 1) {
      a++;
      ans += ar[i].co * a;
    } else {
      ans += ar[i].co * a;
      a++;
    }
  }
  cout << ans << endl;
}
