#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void amin(T &x, const T &y) {
  if (y < x) x = y;
}
template <class T>
inline void amax(T &x, const T &y) {
  if (x < y) x = y;
}
using LL = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 10;
int n, m;
int pri(char ch) {
  if (ch == '+' || ch == '-') return 0;
  if (ch == '*') return 1;
  cout << ch << endl;
  assert(false);
}
int calc(int a, char op, int b) {
  {
    cerr << "\033[94m" << __func__ << " "
         << "a"
         << ": " << (a) << "\n\033[0m";
  }
  {
    cerr << "\033[94m" << __func__ << " "
         << "op"
         << ": " << (op) << "\n\033[0m";
  }
  {
    cerr << "\033[94m" << __func__ << " "
         << "b"
         << ": " << (b) << "\n\033[0m";
  }
  if (op == '+')
    return a + b;
  else if (op == '-')
    return a - b;
  else if (op == '*')
    return a * b;
  assert(false);
}
bool isD(char ch) { return ch >= '0' && ch <= '9'; }
struct Node {
  int co;
  int type;
  Node(int _co, int _type) : co(_co), type(_type) {}
};
void MAIN() {
  int a;
  string s;
  cin >> a;
  cin >> s;
  n = (int)s.size();
  vector<Node> vec;
  for (int i = 0; i < n;) {
    bool neg = false;
    if (s[i] == '-')
      neg = true, i++;
    else if (i && s[i] == '+')
      i++;
    int x = 1;
    if (isD(s[i])) {
      x = 0;
      while (i < n && isD(s[i])) x = x * 10 + s[i] - '0', i++;
      assert(s[i++] == '*');
    }
    if (neg) x = -x;
    assert(n - i >= 3);
    string t = s.substr(i, 3);
    {
      cerr << "\033[94m" << __func__ << " "
           << "x"
           << ": " << (x) << "\n\033[0m";
    }
    {
      cerr << "\033[94m" << __func__ << " "
           << "t"
           << ": " << (t) << "\n\033[0m";
    }
    if (t == "++a") {
      vec.emplace_back(x, 1);
    } else if (t == "a++") {
      vec.emplace_back(x, 0);
    } else {
      assert(false);
    }
    i += 3;
  }
  LL res = 0;
  sort(vec.begin(), vec.end(), [](Node a, Node b) { return a.co < b.co; });
  for (auto &p : vec) {
    if (p.type == 1)
      res += p.co * (++a);
    else
      res += p.co * (a++);
  }
  cout << res << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int TC = 1;
  for (int tc = (0); tc < (TC); tc++) {
    MAIN();
  }
  return 0;
}
