#include <bits/stdc++.h>
using namespace std;
double const pi = 3.1415926535897932384626433832795;
int const inf = (int)1e9;
long long const inf64 = (long long)2e18;
const string task = "";
char s[100000];
int a, l, zn;
long long d[1010][1010];
vector<int> q[2];
void get() {
  int k = 0;
  if (s[l] >= '0' && s[l] <= '9') {
    while (s[l] != '*') {
      k = k * 10 + s[l] - '0';
      l++;
    }
    l++;
  } else
    k = 1;
  k *= zn;
  int tp;
  if (s[l] == 'a')
    tp = 0;
  else
    tp = 1;
  l += 3;
  q[tp].push_back(k);
}
int main() {
  cin >> a;
  scanf("%s", s);
  s[strlen(s) + 1] = '\0';
  s[strlen(s)] = '@';
  l = 0, zn = 1;
  while (true) {
    get();
    if (s[l] == '@') break;
    if (s[l] == '+')
      zn = 1;
    else
      zn = -1;
    l++;
  }
  sort((q[0]).begin(), (q[0]).end());
  sort((q[1]).begin(), (q[1]).end());
  for (int i = 0; i < (int)q[0].size() + 1; i++)
    for (int j = 0; j < (int)q[1].size() + 1; j++) d[i][j] = -inf64;
  d[0][0] = 0;
  for (int i = 0; i < (int)q[0].size() + 1; i++)
    for (int j = 0; j < (int)q[1].size() + 1; j++)
      if (d[i][j] == -inf64) {
        if (i > 0)
          d[i][j] = max(d[i][j], d[i - 1][j] + q[0][i - 1] * (a + i + j - 1));
        if (j > 0)
          d[i][j] = max(d[i][j], d[i][j - 1] + q[1][j - 1] * (a + i + j));
      }
  cout << d[q[0].size()][q[1].size()] << endl;
  return 0;
}
