#include <bits/stdc++.h>
using namespace std;
int N, M, A, ans;
char S[10005];
pair<int, int> a[1005];
int main() {
  scanf("%d%s", &A, S + 1), N = strlen(S + 1);
  for (int i = 1, t = 1; i <= N; i++) {
    int x = isdigit(S[i]) ? 0 : 1;
    for (; isdigit(S[i]); i++) (x *= 10) += S[i] - 48;
    if (S[i] == '*') i++;
    a[++M] = make_pair(x * t, A - (S[i] == 'a' ? 1 : 0)), i += 3,
    t = S[i] == '+' ? 1 : -1;
  }
  sort(a + 1, a + M + 1);
  for (int i = 1; i <= M; i++) ans += a[i].first * (a[i].second + i);
  printf("%d\n", ans);
}
