#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <stdlib.h>
#include <sstream>
#include <assert.h>
#include <memory.h>

#include <time.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define sz(x) (int)(x).size()

struct slag {
	int koef;
	bool post;
	bool sign;
};

slag mas[1111];
bool vis[1111];

int main() {
    //freopen("dual.in","rt",stdin);
    //freopen("dual.out","wt",stdout);
    //freopen("input.txt","rt",stdin);

	int a;
	scanf("%d", &a);
	string s;
	cin >> s;
	int n = sz(s);
	int cnt = 0;
	int ccc = 1; // этап (0 - считывание знака, 1 - считывание коэффициента, 2 - считывание переменной и ++)
	int cntplus = 0;
	int cntminus = 0;
	for(int i = 0; i < n; i++) {
		if(ccc == 0) {
			if(s[i] == '+') {
				mas[cnt].sign = false;
				cntplus++;
			}
			else {
				mas[cnt].sign = true;
				cntminus++;
			}
			ccc++;
		}
		else if(ccc == 1) {
			if(s[i] >= '0' && s[i] <= '9') {
				int p = i;
				int val = 0;
				while(s[p] >= '0' && s[p] <= '9') val *= 10, val += s[p]-'0', p++;
				mas[cnt].koef = val;
				i = p;
				ccc++;
				continue;
			}
			else {
				mas[cnt].koef = 1;
				ccc++;
				i--;
				continue;
			}
		}
		else {
			if(s[i] == '+') {
				i+=2;
				mas[cnt].post = false;
				ccc = 0;
				cnt++;
			}
			else if(s[i] == 'a') {
				i+=2;
				mas[cnt].post = true;
				ccc = 0;
				cnt++;
			}
		}
	}
	/*printf("%d\n", cnt);
	for(int i = 0; i < cnt; i++) {
		if(mas[i].sign) printf("-");
		printf("%d * ", mas[i].koef);
		if(mas[i].post) printf("a++\n");
		else printf("++a\n");
	}*/

	int ost = cnt;
	ll res = 0;
	while(ost > 0) {
		if(cntminus) {
			int bestid = -1;
			ll bestval = 0; // сколько я отниму
			int bestk = 0;
			for(int i = 0; i < cnt; i++) {
				if(mas[i].sign == true && !vis[i]) {
					ll val;
					int k = mas[i].koef;
					if(mas[i].post) {
						val = -(ll)a * (ll)mas[i].koef;
					}
					else {
						val = -(ll)(a+1) * (ll)mas[i].koef;
					}
					if(k > bestk || k == bestk && val > bestval || bestid == -1) bestk = k, bestval = val, bestid = i;
				}
			}
			cntminus--;
			vis[bestid] = true;
			res += bestval;
		}
		else {
			int bestid = -1;
			ll bestval = 0; // сколько я отниму
			int bestk = 0;
			for(int i = 0; i < cnt; i++) {
				if(mas[i].sign == false && !vis[i]) {
					ll val;
					int k = mas[i].koef;
					if(mas[i].post) {
						val = (ll)a * (ll)mas[i].koef;
					}
					else {
						val = (ll)(a+1) * (ll)mas[i].koef;
					}
					if(k < bestk || k == bestk && val < bestval || bestid == -1) bestk = k, bestval = val, bestid = i;
				}
			}
			cntplus--;
			vis[bestid] = true;
			res += bestval;
		}
		ost--;
		a++;
	}
	printf("%lld\n", res);

    return 0;
}


#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <stdlib.h>
#include <sstream>
#include <assert.h>
#include <memory.h>

#include <time.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define sz(x) (int)(x).size()

struct slag {
	int koef;
	bool post;
	bool sign;
};

slag mas[1111];
bool vis[1111];

int main() {
    //freopen("dual.in","rt",stdin);
    //freopen("dual.out","wt",stdout);
    //freopen("input.txt","rt",stdin);

	int a;
	scanf("%d", &a);
	string s;
	cin >> s;
	int n = sz(s);
	int cnt = 0;
	int ccc = 1; // этап (0 - считывание знака, 1 - считывание коэффициента, 2 - считывание переменной и ++)
	int cntplus = 0;
	int cntminus = 0;
	for(int i = 0; i < n; i++) {
		if(ccc == 0) {
			if(s[i] == '+') {
				mas[cnt].sign = false;
				cntplus++;
			}
			else {
				mas[cnt].sign = true;
				cntminus++;
			}
			ccc++;
		}
		else if(ccc == 1) {
			if(s[i] >= '0' && s[i] <= '9') {
				int p = i;
				int val = 0;
				while(s[p] >= '0' && s[p] <= '9') val *= 10, val += s[p]-'0', p++;
				mas[cnt].koef = val;
				i = p;
				ccc++;
				continue;
			}
			else {
				mas[cnt].koef = 1;
				ccc++;
				i--;
				continue;
			}
		}
		else {
			if(s[i] == '+') {
				i+=2;
				mas[cnt].post = false;
				ccc = 0;
				cnt++;
			}
			else if(s[i] == 'a') {
				i+=2;
				mas[cnt].post = true;
				ccc = 0;
				cnt++;
			}
		}
	}
	/*printf("%d\n", cnt);
	for(int i = 0; i < cnt; i++) {
		if(mas[i].sign) printf("-");
		printf("%d * ", mas[i].koef);
		if(mas[i].post) printf("a++\n");
		else printf("++a\n");
	}*/

	int ost = cnt;
	ll res = 0;
	while(ost > 0) {
		if(cntminus) {
			int bestid = -1;
			ll bestval = 0; // сколько я отниму
			for(int i = 0; i < cnt; i++) {
				if(mas[i].sign == true && !vis[i]) {
					ll val;
					if(mas[i].post) {
						val = -(ll)a * (ll)mas[i].koef;
					}
					else {
						val = -(ll)(a+1) * (ll)mas[i].koef;
					}
					if(val > bestval || bestid == -1) bestval = val, bestid = i;
				}
			}
			cntminus--;
			vis[bestid] = true;
			res += bestval;
		}
		else {
			int bestid = -1;
			ll bestval = 0; // сколько я отниму
			for(int i = 0; i < cnt; i++) {
				if(mas[i].sign == false && !vis[i]) {
					ll val;
					if(mas[i].post) {
						val = (ll)a * (ll)mas[i].koef;
					}
					else {
						val = (ll)(a+1) * (ll)mas[i].koef;
					}
					if(val < bestval || bestid == -1) bestval = val, bestid = i;
				}
			}
			cntplus--;
			vis[bestid] = true;
			res += bestval;
		}
		ost--;
		a++;
	}
	printf("%lld\n", res);

    return 0;
}


#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <cassert>
#include <float.h>

using namespace std;

#define REP(i, from, to) for (int i = (from); i < (to); ++i)
#define FOR(i, n) REP(i, 0, (n))
#define ALL(x) x.begin(), x.end()
#define SIZE(x) (int)x.size()
#define PB push_back
#define MP make_pair

typedef long long i64;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef pair<int, int> PII;

struct term {
  int coeff;
  int sign;
  int type; // 0 : prefix, 1 : suffix
};

int a;

int calc(term const& t, int& a) {
  int value;
  if (t.type == 0)
    value = ++a;
  else
    value = a++;
  return t.coeff * value;
}

bool operator<(term const& t1, term const& t2) {
  if (t1.sign < t2.sign)
    return true;
  if (t1.sign > t2.sign)
    return false;

  int atmp1 = a;
  int value1 = calc(t1, atmp1);
  value1 += calc(t2, atmp1);

  int atmp2 = a;
  int value2 = calc(t2, atmp2);
  value2 += calc(t1, atmp2);

  return value1 > value2;
}

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  cin >> a;

  string expr;
  cin >> expr;

  vector<term> terms;
  int i = 0;
  while (i < SIZE(expr)) {
    term t = {1, 0};
    int sign = 1;
    if (i) {
      if (expr[i] == '-')
        sign *= -1;
      ++i;
    }

    if (isdigit(expr[i])) {
      t.coeff = 0;
      while (isdigit(expr[i]))
        t.coeff = t.coeff * 10 + (expr[i++] - '0');
      ++i; // skip *
    }

    if (expr[i] == 'a') {
      t.type = 1;
    } else {
      t.type = 0;
    }

    i += 3; // skip a++ or ++a

    t.coeff *= sign;
    t.sign = sign;
    if (t.coeff == 0)
      t.sign = 1;
    terms.PB(t);
  }

  int res = 0;
  FOR (i, SIZE(terms)) {
    sort(terms.begin() + i, terms.end());
    res += calc(terms[i], a);
  }

  cout << res << "\n";

  return 0;
}


#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <cassert>
#include <float.h>

using namespace std;

#define REP(i, from, to) for (int i = (from); i < (to); ++i)
#define FOR(i, n) REP(i, 0, (n))
#define ALL(x) x.begin(), x.end()
#define SIZE(x) (int)x.size()
#define PB push_back
#define MP make_pair

typedef long long i64;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef pair<int, int> PII;

struct term {
  int coeff;
  int type; // 0 : prefix, 1 : suffix
};

int a;

int calc(term const& t, int& a) {
  int value;
  if (t.type == 0)
    value = ++a;
  else
    value = a++;
  return t.coeff * value;
}

bool operator<(term const& t1, term const& t2) {
  int atmp1 = a;
  int atmp2 = a;
  return calc(t1, atmp1) < calc(t2, atmp2);
}

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  cin >> a;

  string expr;
  cin >> expr;

  vector<term> terms;
  int i = 0;
  while (i < SIZE(expr)) {
    term t = {1, 0};
    int sign = 1;
    if (i) {
      if (expr[i] == '-')
        sign *= -1;
      ++i;
    }

    if (isdigit(expr[i])) {
      t.coeff = 0;
      while (isdigit(expr[i]))
        t.coeff = t.coeff * 10 + (expr[i++] - '0');
      ++i; // skip *
    }

    if (expr[i] == 'a') {
      t.type = 1;
    } else {
      t.type = 0;
    }

    i += 3; // skip a++ or ++a

    t.coeff *= sign;
    terms.PB(t);
  }

  int res = 0;
  FOR (i, SIZE(terms)) {
    sort(terms.begin() + i, terms.end());
    res += calc(terms[i], a);
  }

  cout << res << "\n";

  return 0;
}


#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <cassert>
#include <float.h>

using namespace std;

#define REP(i, from, to) for (int i = (from); i < (to); ++i)
#define FOR(i, n) REP(i, 0, (n))
#define ALL(x) x.begin(), x.end()
#define SIZE(x) (int)x.size()
#define PB push_back
#define MP make_pair

typedef long long i64;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef pair<int, int> PII;

struct term {
  int coeff;
  int type; // 0 : prefix, 1 : suffix
};

int a;

int calc(term const& t, int& a) {
  int value;
  if (t.type == 0)
    value = ++a;
  else
    value = a++;
  return t.coeff * value;
}

bool operator<(term const& t1, term const& t2) {
  int atmp = a;
  return calc(t1, atmp) < calc(t2, atmp);
}

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  cin >> a;

  string expr;
  cin >> expr;

  vector<term> terms;
  int i = 0;
  while (i < SIZE(expr)) {
    term t = {1, 0};
    int sign = 1;
    if (i) {
      if (expr[i] == '-')
        sign *= -1;
      ++i;
    }

    if (isdigit(expr[i])) {
      t.coeff = 0;
      while (isdigit(expr[i]))
        t.coeff = t.coeff * 10 + (expr[i++] - '0');
      ++i; // skip *
    }

    if (expr[i] == 'a') {
      t.type = 1;
    } else {
      t.type = 0;
    }

    i += 3; // skip a++ or ++a

    t.coeff *= sign;
    terms.PB(t);
  }

  int res = 0;
  FOR (i, SIZE(terms)) {
    sort(terms.begin() + i, terms.end());
    res += calc(terms[i], a);
  }

  cout << res << "\n";

  return 0;
}


// A.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int a;
string text;
vector< int > mas;
int res = 0;

int main()
{
	cin >> a;
	cin >> text;
	int state = 0;
	// sum - 0
	// coef - 1
	// inc - 2
	int i = 0, num = 0, sign = 1, inc = 0;
	while (i < (int)text.size())
	{
		switch (state)
		{
		// sum
		case 0:
			if (text[i] >= '0' && text[i] <= '9')
			{
				state = 1;
				num = 0;
			}
			else
			{
				state = 2;
				num = 1;
			}
			break;
		// coef
		case 1:
			while (text[i] >= '0' && text[i] <= '9')
			{
				num *= 10;
				num += text[i] - '0';
				i++;
			}
			if (text[i] == '*')
			{
				state = 2;
				i++;
			}
			break;
		// inc
		case 2:
			if (text[i] == '+')
			{
				inc = 1;
			}
			else
			{
				inc = -1;
			}
			i += 3;
			mas.push_back(num * sign);
			if (inc == 1)
				res += num * sign;
			if (text[i] == '-')
				sign = -1;
			else
				sign = 1;
			state = 0;
			i++;
			break;
		}
	}
	sort(mas.begin(), mas.end());
	for (int i = 0; i < (int)mas.size(); i++)
	{
		res += mas[i] * (i + a);
	}
	cout << res << endl;
	return 0;
}


#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <ctime>
#include <queue>
#include <cstring>
#include <map>
#include <sstream>
#include <fstream>
using namespace std;
#define rp(i,n) for(int (i)=0;(i)<(n);++(i))
#define pb push_back
#define L(s) (int)s.size()
#define mp make_pair
#define pii pair<int,int>
#define x first
#define y second
#define inf 1000000000
#define VI vector<int>
#define ll long long
#define C(a) memset((a),0,sizeof((a)))
int a;
char s[1111];
int n;
int sgn=1;
vector< pii > v;
int main()
{
	gets(s);
	sscanf(s,"%d",&a);
	gets(s);
	n=(int)strlen(s);
	int i=0;
	while(i<n)
	{
		int cf=1;
		if (s[i]!='a'&&s[i]!='+')
		{
			cf=0;
			while(s[i]>='0'&&s[i]<='9')
				cf=cf*10+(s[i++]-'0');
			i++;
		}
		if (s[i]=='a')
			v.pb(mp(sgn*cf,0));
		else
			v.pb(mp(sgn*cf,1));
		if (i+3<n&&s[i+3]=='+')
			sgn=1;
		else
			if (i+3<n&&s[i+3]=='-')
				sgn=-1;
		i+=4;
	}
	sort(v.begin(),v.end());
	int ans=0;
	rp(i,L(v))
		if (v[i].y==0)
			ans+=v[i].x*(a++);
		else
			ans+=v[i].x*(++a);
	cout<<ans<<endl;
}


#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <ctime>
#include <queue>
#include <cstring>
#include <map>
#include <sstream>
#include <fstream>
using namespace std;
#define rp(i,n) for(int (i)=0;(i)<(n);++(i))
#define pb push_back
#define L(s) (int)s.size()
#define mp make_pair
#define pii pair<int,int>
#define x first
#define y second
#define inf 1000000000
#define VI vector<int>
#define ll long long
#define C(a) memset((a),0,sizeof((a)))
int a;
char s[111111];
int n;
int sgn=1;
vector< pii > v;
int main()
{
	gets(s);
	sscanf(s,"%d",&a);
	gets(s);
	n=(int)strlen(s);
	int i=0;
	while(i<n)
	{
		int cf=1;
		if (s[i]!='a'&&s[i]!='+')
		{
			cf=0;
			while(s[i]>='0'&&s[i]<='9')
				cf=cf*10+(s[i++]-'0');
			i++;
		}
		if (s[i]=='a')
			v.pb(mp(sgn*cf,0));
		else
			v.pb(mp(sgn*cf,1));
		if (i+3<n&&s[i+3]=='+')
			sgn=1;
		else
			if (i+3<n&&s[i+3]=='-')
				sgn=-1;
		i+=4;
	}
	sort(v.begin(),v.end());
	int ans=0;
	rp(i,L(v))
		if (v[i].y==0)
			ans+=v[i].x*(a++);
		else
			ans+=v[i].x*(++a);
	cout<<ans<<endl;
}


#pragma comment(linker, "/stack:64000000")
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES

#include <algorithm>
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cstring>
#include <complex>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <ctime>
#include <set>
#include <map>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define for1(i, n) for (int i = 1; i <= int(n); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define debug(x) cerr << #x << " = " << x << endl;
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair((a), (b))
#define X first
#define Y second
#define ft first
#define sc second

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

typedef long double ld;
typedef pair<ld, ld> ptd;
typedef pair <int, int> pt;
typedef long long li;
typedef unsigned char byte;

const ld PI = 3.1415926535897932384626433832795;
const ld EPS = 1e-9;
const li INF = li(1e18);

int val, n;
string s;
vector <pt> v;
int pos = 0;

pt expr ()
{
    int k = 1, type = 0;

    string cur = "";

    while (s[pos] >= '0' && s[pos] <= '9')
        cur.pb(s[pos++]);

    if (!cur.empty())
        k = atoi(cur.c_str()), pos++;

    if (s[pos] == 'a')
        type = 1;

    pos += 3;

    return mp(k, type);
}

void unary ()
{
    while (pos < n)
    {
        char c = s[pos++];

        pt t = expr();

        if (c == '-')
            t.ft *= -1;

        v.pb(t);
    }
}

int main()
{

    cin >> val;

    cin >> s;

    s = "+" + s;

    n = sz(s);

    unary();

    sort(all(v));

    li ans = 0;

    forn(i, sz(v))
    {
        if (v[i].sc == 0)
            val++;

        ans += v[i].ft * val;

        if (v[i].sc == 1)
            val++;
    }

    cout << ans << endl;

    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

//int main()
//{
//	int x1, y1, z1;
//	cin >> x1 >> y1 >> z1;
//	int x2, y2, z2;
//	cin >> x2 >> y2 >> z2;
//	if(abs(x1-x2)+abs(y1-y2) + abs(z1-z2) == 3)
//		cout << "NO";
//	else
//		cout << "YES";
//	return 0;
//}
//int main()
//{
//	int n;
//	cin >> n;
//	vector< vector<string > > vec;
//	vec.resize(n - 1);
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i].resize(n-1);
//	}
//
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i][0] = (i + 1) + '0';
//		vec[0][i] = (i + 1)  + '0';
//	}
//	for(int i = 1; i < n -1; i++)
//	{
//		for(int j = 1; j < n -1; j++)
//		{
//			vector<char> t;
//			const char* ch1 = vec[i][0].c_str();
//			char ch11 = ch1[0];
//			int p1 =  ch11 - '0';
//
//			const char* ch2 = vec[0][j].c_str();
//			char ch22 = ch2[0];
//			int p2 =  ch22 - '0';
//
//			int temp = p1 * p2;
//			while(temp > 0)
//			{
//
//				t.push_back((temp % n) + '0');
//				temp /= n;
//			}
//			reverse(t.begin(), t.end());
//			for(int p = 0; p < t.size(); p++)
//			{
//				vec[i][j] += t[p];
//			}
//		}
//	}
//	for(int i = 0; i < n - 1; i++)
//	{
//		for(int j = 0; j < n - 1 ; j++)
//			cout << vec[i][j] << " ";
//		cout << endl;
//	}
//	return 0;
////}
struct summand
{
	int koef;
	string incr;
	bool used;
};
vector<summand> vec;
int FindMin(int& a, bool fl)
{
	int min = 100*100*100;
	int minInd =0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = 100*100*100;
		if(!fl && vec[i].koef > 0 && vec[i].used == 1)
		{
			temp = vec[i].koef;
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a+1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+1;
				temp++;
			}
		}
		else if(fl && vec[i].koef < 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a+1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+1;
				temp++;
			}
		}
		if(temp < min)
		{
			min = temp;
			minInd = i;
		}
	}
	vec[minInd].used = 0;
	if(vec[minInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	if(fl)
		return -min;
	else
		return min;
}
int FindMax(int& a, bool fl)
{
	int max = -100*100*100;
	int maxInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = -100*100*100;
		if(fl && vec[i].koef < 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		else if(!fl && vec[i].koef > 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		if(temp > max)
		{
			max = temp;
			maxInd = i;
		}
	}
	vec[maxInd].used = 0;
	if(vec[maxInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	if(fl)
		return -max;
	else
		return max;
}
int cmp(summand a1, summand a2)
{
	if(a1.koef < a2.koef)
		return 1;
	else if(a1.koef > a2.koef)
		return -1;
	else
		return 0;
}
void Check(int a)
{
	int otrCount = 0;
	int polCount = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		vec[i].used = 1;
		if(vec[i].koef < 0)
			otrCount++;
		else
			polCount++;
	}
	int ans = 0;
	if(a > 0)
	{
		while(otrCount > 0)
		{
			ans += FindMax(a,true);
			otrCount--;
		}
		//cout << ans;
		while(polCount > 0)
		{
			ans += FindMin(a,false);
			polCount--;
		}
			cout << ans;

	}
	else
	{
		//int tempA = a;
		//int ans1 = 0;
		//while(polCount > 0)
		//{
		//	ans1 += FindMin(a,false);
		//	polCount--;
		//}
		//while(otrCount > 0)
		//{
		//	ans1 += FindMax(a,true);
		//	otrCount--;
		//}
		//cout << ans;

		int ans2 = 0;
		while(otrCount > 0)
		{
			ans += FindMin(a,true);
			otrCount--;
		}
		while(polCount > 0)
		{
			ans2 += FindMax(a,false);
			polCount--;
		}
		//if(ans1 > ans2)
		//	cout << ans1;
		//else
		//	cout << ans2;

		cout << ans2;

	}
}
void Parse(string& str)
{
	int s = str.size();
	bool minus = false;
	for(int i = 0; i < s; i++)
	{
		char ch = str[i];
		summand sd;
		if(ch == '-')
		{
			//vec.push_back(sd);
			minus = true;
		}
		else if(isdigit(ch))
		{
			string koef;
			koef += ch;
			while(i < str.size() - 1 && isdigit(ch))
			{
				i++;
				ch = str[i];
				if(isdigit(ch))
				{
					koef += ch;
				}
				else
					i--;
			}
			int tens = 1;
			for(int i = 0; i < koef.size() - 1; i++)
			{
				tens *= 10;
			}
			int koef2 = 0;
			for(int i = 0; i < koef.size(); i++)
			{
				char ch2 = koef[i];
				int t = (ch2 - '0') * tens;
				tens /= 10;
				koef2 += t;
			}
			if(minus)
				koef2 = (-1)*koef2;
			sd.koef = koef2;
			//cout << "k \n";
			//cout << koef2;
			i++; // *
			i++;
			string incr;
			if(isalpha(char(str[i])))
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p-1;
			}
			else if((char)str[i] == '+')
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p - 1;
				if(i+1 < str.size() && i+2 < str.size() && ((char)str[i+1] == '+' && (char)str[i+2] == '+'))
				{
					int p = 1;
					while(p <= 2)
					{
						incr += str[i + p++];
					}
					i = i + p-1;
				}
			}
			sd.incr = incr;
			//cout << incr;
			vec.push_back(sd);
			minus = false;

		}
		else if (isalpha(ch))
		{
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
		else if(ch == '+')
		{
			if(isalpha((char)str[i+1]) || isdigit((char)str[i+1]) || (str[i+1] == '+' && str[i+2] =='+'))
			{
				//vec.push_back(sd);
				continue;
			}
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			if(i+1 < str.size() && (char)str[i+1] == '+')
			{
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p;
			}
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
	}

	//cout << endl;
	//for(int i = 0; i < vec.size(); i++)
		//cout << vec[i].incr << " " << vec[i].koef << endl;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	int a;
	cin >> a;
	string str;
	cin >> str;
	Parse(str);
	Check(a);
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

//int main()
//{
//	int x1, y1, z1;
//	cin >> x1 >> y1 >> z1;
//	int x2, y2, z2;
//	cin >> x2 >> y2 >> z2;
//	if(abs(x1-x2)+abs(y1-y2) + abs(z1-z2) == 3)
//		cout << "NO";
//	else
//		cout << "YES";
//	return 0;
//}
//int main()
//{
//	int n;
//	cin >> n;
//	vector< vector<string > > vec;
//	vec.resize(n - 1);
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i].resize(n-1);
//	}
//
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i][0] = (i + 1) + '0';
//		vec[0][i] = (i + 1)  + '0';
//	}
//	for(int i = 1; i < n -1; i++)
//	{
//		for(int j = 1; j < n -1; j++)
//		{
//			vector<char> t;
//			const char* ch1 = vec[i][0].c_str();
//			char ch11 = ch1[0];
//			int p1 =  ch11 - '0';
//
//			const char* ch2 = vec[0][j].c_str();
//			char ch22 = ch2[0];
//			int p2 =  ch22 - '0';
//
//			int temp = p1 * p2;
//			while(temp > 0)
//			{
//
//				t.push_back((temp % n) + '0');
//				temp /= n;
//			}
//			reverse(t.begin(), t.end());
//			for(int p = 0; p < t.size(); p++)
//			{
//				vec[i][j] += t[p];
//			}
//		}
//	}
//	for(int i = 0; i < n - 1; i++)
//	{
//		for(int j = 0; j < n - 1 ; j++)
//			cout << vec[i][j] << " ";
//		cout << endl;
//	}
//	return 0;
////}
struct summand
{
	int koef;
	string incr;
	bool used;
};
vector<summand> vec;
int FindMax2(int& a)
{
	int max = -100*100*100;
	int maxInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = -100*100*100;
		if(vec[i].used == 1 && vec[i].koef < 0)
		{
			temp = vec[i].koef;
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		if(max < temp)
		{
			max = temp;
			maxInd = i;
		}
	}
	vec[maxInd].used = 0;
	if(vec[maxInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	return max;
}
int FindMin2(int& a)
{
	int min = 100*100*100;
	int minInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = 100*100*100;
		if(vec[i].used == 1 && vec[i].koef > 0)
		{
			temp = vec[i].koef;
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		if(min > temp)
		{
			min = temp;
			minInd = i;
		}
	}
	vec[minInd].used = 0;
	if(vec[minInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	return min;
}
int FindMaxKoef(int& a)
{
	int max = -100*100*100;
	int maxInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		if(vec[i].koef > max && vec[i].used == 1)
		{
			max = vec[i].koef;
			maxInd = i;
		}
	}
	int temp = max;
	if(vec[maxInd].incr.size() == 3)
	{
		if(vec[maxInd].incr[0] == '+')
		{
			//a++;
			temp *= a + 1;
		}
		else
		{
			temp *=a;
			//a++;
		}
	}
	else
	{
		//a++;
		temp *=a+ 1;
		temp++;
	}
	vec[maxInd].used = 0;
	if(vec[maxInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	return temp;
}
int FindMinKoef(int& a)
{
	int min = 100*100*100;
	int minInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		if(vec[i].koef < min && vec[i].used == 1)
		{
			min = vec[i].koef;
			minInd = i;
		}
	}
	int temp = min;
	if(vec[minInd].incr.size() == 3)
	{
		if(vec[minInd].incr[0] == '+')
		{
			//a++;
			temp *= a + 1;
		}
		else
		{
			temp *=a;
			//a++;
		}
	}
	else
	{
		//a++;
		temp *=a+ 1;
		temp++;
	}
	vec[minInd].used = 0;
	if(vec[minInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	return temp;
}
void Check(int a)
{
	int otrCount = 0;
	int polCount = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		vec[i].used = 1;
		if(vec[i].koef < 0)
			otrCount++;
		else
			polCount++;
	}
        int ans = 0;
    //    while(otrCount > 0)
    //    {
    //            //ans += FindMax2(a);
				//ans +=FindMinKoef(a);
    //            otrCount--;
    //    }
    //    //cout << ans;
        while(polCount + otrCount > 0)
        {
                //ans += FindMin2(a);
				ans += FindMinKoef(a);
                polCount--;
        }
        cout << ans;
}
void Parse(string& str)
{
	int s = str.size();
	bool minus = false;
	for(int i = 0; i < s; i++)
	{
		char ch = str[i];
		summand sd;
		if(ch == '-')
		{
			//vec.push_back(sd);
			minus = true;
		}
		else if(isdigit(ch))
		{
			string koef;
			koef += ch;
			while(i < str.size() - 1 && isdigit(ch))
			{
				i++;
				ch = str[i];
				if(isdigit(ch))
				{
					koef += ch;
				}
				else
					i--;
			}
			int tens = 1;
			for(int i = 0; i < koef.size() - 1; i++)
			{
				tens *= 10;
			}
			int koef2 = 0;
			for(int i = 0; i < koef.size(); i++)
			{
				char ch2 = koef[i];
				int t = (ch2 - '0') * tens;
				tens /= 10;
				koef2 += t;
			}
			if(minus)
				koef2 = (-1)*koef2;
			sd.koef = koef2;
			//cout << "k \n";
			//cout << koef2;
			i++; // *
			i++;
			string incr;
			if(isalpha(char(str[i])))
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p-1;
			}
			else if((char)str[i] == '+')
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p - 1;
				if(i+1 < str.size() && i+2 < str.size() && ((char)str[i+1] == '+' && (char)str[i+2] == '+'))
				{
					int p = 1;
					while(p <= 2)
					{
						incr += str[i + p++];
					}
					i = i + p-1;
				}
			}
			sd.incr = incr;
			//cout << incr;
			vec.push_back(sd);
			minus = false;

		}
		else if (isalpha(ch))
		{
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
		else if(ch == '+')
		{
			if(isalpha((char)str[i+1]) || isdigit((char)str[i+1]) || (str[i+1] == '+' && str[i+2] =='+'))
			{
				//vec.push_back(sd);
				continue;
			}
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			if(i+1 < str.size() && (char)str[i+1] == '+')
			{
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p;
			}
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
	}

	//cout << endl;
	//for(int i = 0; i < vec.size(); i++)
		//cout << vec[i].incr << " " << vec[i].koef << endl;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	int a;
	cin >> a;
	string str;
	cin >> str;
	Parse(str);
	Check(a);
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

//int main()
//{
//	int x1, y1, z1;
//	cin >> x1 >> y1 >> z1;
//	int x2, y2, z2;
//	cin >> x2 >> y2 >> z2;
//	if(abs(x1-x2)+abs(y1-y2) + abs(z1-z2) == 3)
//		cout << "NO";
//	else
//		cout << "YES";
//	return 0;
//}
//int main()
//{
//	int n;
//	cin >> n;
//	vector< vector<string > > vec;
//	vec.resize(n - 1);
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i].resize(n-1);
//	}
//
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i][0] = (i + 1) + '0';
//		vec[0][i] = (i + 1)  + '0';
//	}
//	for(int i = 1; i < n -1; i++)
//	{
//		for(int j = 1; j < n -1; j++)
//		{
//			vector<char> t;
//			const char* ch1 = vec[i][0].c_str();
//			char ch11 = ch1[0];
//			int p1 =  ch11 - '0';
//
//			const char* ch2 = vec[0][j].c_str();
//			char ch22 = ch2[0];
//			int p2 =  ch22 - '0';
//
//			int temp = p1 * p2;
//			while(temp > 0)
//			{
//
//				t.push_back((temp % n) + '0');
//				temp /= n;
//			}
//			reverse(t.begin(), t.end());
//			for(int p = 0; p < t.size(); p++)
//			{
//				vec[i][j] += t[p];
//			}
//		}
//	}
//	for(int i = 0; i < n - 1; i++)
//	{
//		for(int j = 0; j < n - 1 ; j++)
//			cout << vec[i][j] << " ";
//		cout << endl;
//	}
//	return 0;
////}
struct summand
{
	int koef;
	string incr;
	bool used;
};
vector<summand> vec;
int FindMax2(int& a)
{
	int max = -100*100*100;
	int maxInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = -100*100*100;
		if(vec[i].used == 1 && vec[i].koef < 0)
		{
			temp = vec[i].koef;
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		if(max < temp)
		{
			max = temp;
			maxInd = i;
		}
	}
	vec[maxInd].used = 0;
	if(vec[maxInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	return max;
}
int FindMin2(int& a)
{
	int min = 100*100*100;
	int minInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = 100*100*100;
		if(vec[i].used == 1 && vec[i].koef > 0)
		{
			temp = vec[i].koef;
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		if(min > temp)
		{
			min = temp;
			minInd = i;
		}
	}
	vec[minInd].used = 0;
	if(vec[minInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	return min;
}
int FindMaxKoef(int& a)
{
	int max = -100*100*100;
	int maxInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		if(vec[i].koef > max && vec[i].used == 1)
		{
			max = vec[i].koef;
			maxInd = i;
		}
	}
	int temp = max;
	if(vec[maxInd].incr.size() == 3)
	{
		if(vec[maxInd].incr[0] == '+')
		{
			//a++;
			temp *= a + 1;
		}
		else
		{
			temp *=a;
			//a++;
		}
	}
	//else
	//{
	//	//a++;
	//	temp *=a+ 1;
	//	temp++;
	//}
	vec[maxInd].used = 0;
	if(vec[maxInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	return temp;
}
int FindMinKoef(int& a)
{
	int min = 100*100*100;
	int minInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		if(vec[i].koef < min && vec[i].used == 1)
		{
			min = vec[i].koef;
			minInd = i;
		}
	}
	int temp = min;
	if(vec[minInd].incr.size() == 3)
	{
		if(vec[minInd].incr[0] == '+')
		{
			//a++;
			temp *= a + 1;
		}
		else
		{
			temp *=a;
			//a++;
		}
	}
	//else
	//{
	//	//a++;
	//	temp *=a+ 1;
	//	temp++;
	//}
	vec[minInd].used = 0;
	if(vec[minInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	return temp;
}
void Check(int a)
{
	int otrCount = 0;
	int polCount = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		vec[i].used = 1;
		if(vec[i].koef < 0)
			otrCount++;
		else
			polCount++;
	}
        int ans = 0;
    //    while(otrCount > 0)
    //    {
    //            //ans += FindMax2(a);
				//ans +=FindMinKoef(a);
    //            otrCount--;
    //    }
    //    //cout << ans;
        while(polCount + otrCount > 0)
        {
                //ans += FindMin2(a);
				ans += FindMinKoef(a);
                polCount--;
        }
        cout << ans;
}
void Parse(string& str)
{
	int s = str.size();
	bool minus = false;
	for(int i = 0; i < s; i++)
	{
		char ch = str[i];
		summand sd;
		if(ch == '-')
		{
			//vec.push_back(sd);
			minus = true;
		}
		else if(isdigit(ch))
		{
			string koef;
			koef += ch;
			while(i < str.size() - 1 && isdigit(ch))
			{
				i++;
				ch = str[i];
				if(isdigit(ch))
				{
					koef += ch;
				}
				else
					i--;
			}
			int tens = 1;
			for(int i = 0; i < koef.size() - 1; i++)
			{
				tens *= 10;
			}
			int koef2 = 0;
			for(int i = 0; i < koef.size(); i++)
			{
				char ch2 = koef[i];
				int t = (ch2 - '0') * tens;
				tens /= 10;
				koef2 += t;
			}
			if(minus)
				koef2 = (-1)*koef2;
			sd.koef = koef2;
			//cout << "k \n";
			//cout << koef2;
			i++; // *
			i++;
			string incr;
			if(isalpha(char(str[i])))
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p-1;
			}
			else if((char)str[i] == '+')
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p - 1;
				//if(i+1 < str.size() && i+2 < str.size() && ((char)str[i+1] == '+' && (char)str[i+2] == '+'))
				//{
				//	int p = 1;
				//	while(p <= 2)
				//	{
				//		incr += str[i + p++];
				//	}
				//	i = i + p-1;
				//}
			}
			sd.incr = incr;
			//cout << incr;
			vec.push_back(sd);
			minus = false;

		}
		else if (isalpha(ch))
		{
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
		else if(ch == '+')
		{
			if(isalpha((char)str[i+1]) || isdigit((char)str[i+1]) || (str[i+1] == '+' && str[i+2] =='+'))
			{
				//vec.push_back(sd);
				continue;
			}
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			//if(i+1 < str.size() && (char)str[i+1] == '+')
			//{
			//	int p = 1;
			//	while(p <= 2)
			//	{
			//		incr += str[i + p++];
			//	}
			//	i = i + p;
			//}
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
	}

	cout << endl;
	for(int i = 0; i < vec.size(); i++)
		cout << vec[i].incr << " " << vec[i].koef << endl;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	int a;
	cin >> a;
	string str;
	cin >> str;
	Parse(str);
	Check(a);
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

//int main()
//{
//	int x1, y1, z1;
//	cin >> x1 >> y1 >> z1;
//	int x2, y2, z2;
//	cin >> x2 >> y2 >> z2;
//	if(abs(x1-x2)+abs(y1-y2) + abs(z1-z2) == 3)
//		cout << "NO";
//	else
//		cout << "YES";
//	return 0;
//}
//int main()
//{
//	int n;
//	cin >> n;
//	vector< vector<string > > vec;
//	vec.resize(n - 1);
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i].resize(n-1);
//	}
//
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i][0] = (i + 1) + '0';
//		vec[0][i] = (i + 1)  + '0';
//	}
//	for(int i = 1; i < n -1; i++)
//	{
//		for(int j = 1; j < n -1; j++)
//		{
//			vector<char> t;
//			const char* ch1 = vec[i][0].c_str();
//			char ch11 = ch1[0];
//			int p1 =  ch11 - '0';
//
//			const char* ch2 = vec[0][j].c_str();
//			char ch22 = ch2[0];
//			int p2 =  ch22 - '0';
//
//			int temp = p1 * p2;
//			while(temp > 0)
//			{
//
//				t.push_back((temp % n) + '0');
//				temp /= n;
//			}
//			reverse(t.begin(), t.end());
//			for(int p = 0; p < t.size(); p++)
//			{
//				vec[i][j] += t[p];
//			}
//		}
//	}
//	for(int i = 0; i < n - 1; i++)
//	{
//		for(int j = 0; j < n - 1 ; j++)
//			cout << vec[i][j] << " ";
//		cout << endl;
//	}
//	return 0;
////}
struct summand
{
	int koef;
	string incr;
	bool used;
};
vector<summand> vec;
int FindMin(int& a, bool fl)
{
	int min = 100*100*100;
	int minInd =0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = 100*100*100;
		if(!fl && vec[i].koef > 0 && vec[i].used == 1)
		{
			temp = vec[i].koef;
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a+1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+1;
				temp++;
			}
		}
		else if(fl && vec[i].koef < 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a+1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+1;
				temp++;
			}
		}
		if(temp < min)
		{
			min = temp;
			minInd = i;
		}
	}
	vec[minInd].used = 0;
	if(vec[minInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	if(fl)
		return -min;
	else
		return min;
}
int FindMax(int& a, bool fl)
{
	int max = -100*100*100;
	int maxInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = -100*100*100;
		if(fl && vec[i].koef < 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		else if(!fl && vec[i].koef > 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		if(temp > max)
		{
			max = temp;
			maxInd = i;
		}
	}
	vec[maxInd].used = 0;
	if(vec[maxInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	if(fl)
		return -max;
	else
		return max;
}
int FindMax2(int& a)
{
	int max = -100*100*100;
	int maxInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = -100*100*100;
		if(vec[i].used == 1 && vec[i].koef < 0)
		{
			temp = vec[i].koef;
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		if(max < temp)
		{
			max = temp;
			maxInd = i;
		}
	}
	vec[maxInd].used = 0;
	if(vec[maxInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	return max;
}
int FindMin2(int& a)
{
	int min = 100*100*100;
	int minInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = 100*100*100;
		if(vec[i].used == 1 && vec[i].koef > 0)
		{
			temp = vec[i].koef;
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		if(min > temp)
		{
			min = temp;
			minInd = i;
		}
	}
	vec[minInd].used = 0;
	if(vec[minInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	return min;
}
void Check(int a)
{
	int otrCount = 0;
	int polCount = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		vec[i].used = 1;
		if(vec[i].koef < 0)
			otrCount++;
		else
			polCount++;
	}
        int ans = 0;
        while(otrCount > 0)
        {
                ans += FindMax2(a);
                otrCount--;
        }
        //cout << ans;
        while(polCount > 0)
        {
                ans += FindMin2(a);
                polCount--;
        }
        cout << ans;
}
void Parse(string& str)
{
	int s = str.size();
	bool minus = false;
	for(int i = 0; i < s; i++)
	{
		char ch = str[i];
		summand sd;
		if(ch == '-')
		{
			//vec.push_back(sd);
			minus = true;
		}
		else if(isdigit(ch))
		{
			string koef;
			koef += ch;
			while(i < str.size() - 1 && isdigit(ch))
			{
				i++;
				ch = str[i];
				if(isdigit(ch))
				{
					koef += ch;
				}
				else
					i--;
			}
			int tens = 1;
			for(int i = 0; i < koef.size() - 1; i++)
			{
				tens *= 10;
			}
			int koef2 = 0;
			for(int i = 0; i < koef.size(); i++)
			{
				char ch2 = koef[i];
				int t = (ch2 - '0') * tens;
				tens /= 10;
				koef2 += t;
			}
			if(minus)
				koef2 = (-1)*koef2;
			sd.koef = koef2;
			//cout << "k \n";
			//cout << koef2;
			i++; // *
			i++;
			string incr;
			if(isalpha(char(str[i])))
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p-1;
			}
			else if((char)str[i] == '+')
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p - 1;
				if(i+1 < str.size() && i+2 < str.size() && ((char)str[i+1] == '+' && (char)str[i+2] == '+'))
				{
					int p = 1;
					while(p <= 2)
					{
						incr += str[i + p++];
					}
					i = i + p-1;
				}
			}
			sd.incr = incr;
			//cout << incr;
			vec.push_back(sd);
			minus = false;

		}
		else if (isalpha(ch))
		{
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
		else if(ch == '+')
		{
			if(isalpha((char)str[i+1]) || isdigit((char)str[i+1]) || (str[i+1] == '+' && str[i+2] =='+'))
			{
				//vec.push_back(sd);
				continue;
			}
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			if(i+1 < str.size() && (char)str[i+1] == '+')
			{
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p;
			}
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
	}

	//cout << endl;
	//for(int i = 0; i < vec.size(); i++)
		//cout << vec[i].incr << " " << vec[i].koef << endl;
}
int main()
{
//	freopen("input.txt", "r", stdin);
	int a;
	cin >> a;
	string str;
	cin >> str;
	Parse(str);
	Check(a);
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

//int main()
//{
//	int x1, y1, z1;
//	cin >> x1 >> y1 >> z1;
//	int x2, y2, z2;
//	cin >> x2 >> y2 >> z2;
//	if(abs(x1-x2)+abs(y1-y2) + abs(z1-z2) == 3)
//		cout << "NO";
//	else
//		cout << "YES";
//	return 0;
//}
//int main()
//{
//	int n;
//	cin >> n;
//	vector< vector<string > > vec;
//	vec.resize(n - 1);
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i].resize(n-1);
//	}
//
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i][0] = (i + 1) + '0';
//		vec[0][i] = (i + 1)  + '0';
//	}
//	for(int i = 1; i < n -1; i++)
//	{
//		for(int j = 1; j < n -1; j++)
//		{
//			vector<char> t;
//			const char* ch1 = vec[i][0].c_str();
//			char ch11 = ch1[0];
//			int p1 =  ch11 - '0';
//
//			const char* ch2 = vec[0][j].c_str();
//			char ch22 = ch2[0];
//			int p2 =  ch22 - '0';
//
//			int temp = p1 * p2;
//			while(temp > 0)
//			{
//
//				t.push_back((temp % n) + '0');
//				temp /= n;
//			}
//			reverse(t.begin(), t.end());
//			for(int p = 0; p < t.size(); p++)
//			{
//				vec[i][j] += t[p];
//			}
//		}
//	}
//	for(int i = 0; i < n - 1; i++)
//	{
//		for(int j = 0; j < n - 1 ; j++)
//			cout << vec[i][j] << " ";
//		cout << endl;
//	}
//	return 0;
////}
struct summand
{
	int koef;
	string incr;
	bool used;
};
vector<summand> vec;
int FindMin(int& a, bool fl)
{
	int min = 100*100*100;
	int minInd =0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = 100*100*100;
		if(!fl && vec[i].koef > 0 && vec[i].used == 1)
		{
			temp = vec[i].koef;
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a+1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+1;
				temp++;
			}
		}
		else if(fl && vec[i].koef < 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a+1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+1;
				temp++;
			}
		}
		if(temp < min)
		{
			min = temp;
			minInd = i;
		}
	}
	vec[minInd].used = 0;
	if(vec[minInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	if(fl)
		return -min;
	else
		return min;
}
int FindMax(int& a, bool fl)
{
	int max = -100*100*100;
	int maxInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = -100*100*100;
		if(fl && vec[i].koef < 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		else if(!fl && vec[i].koef > 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		if(temp > max)
		{
			max = temp;
			maxInd = i;
		}
	}
	vec[maxInd].used = 0;
	if(vec[maxInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	if(fl)
		return -max;
	else
		return max;
}
int cmp(summand a1, summand a2)
{
	if(a1.koef < a2.koef)
		return 1;
	else if(a1.koef > a2.koef)
		return -1;
	else
		return 0;
}
void Check(int a)
{
	int otrCount = 0;
	int polCount = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		vec[i].used = 1;
		if(vec[i].koef < 0)
			otrCount++;
		else
			polCount++;
	}
	int ans = 0;
	if(a >= 0)
	{
		while(otrCount > 0)
		{
			ans += FindMax(a,true);
			otrCount--;
		}
		//cout << ans;
		while(polCount > 0)
		{
			ans += FindMin(a,false);
			polCount--;
		}
			cout << ans;

	}
	else
	{
		//int tempA = a;
		//int ans1 = 0;
		//while(polCount > 0)
		//{
		//	ans1 += FindMin(a,false);
		//	polCount--;
		//}
		//while(otrCount > 0)
		//{
		//	ans1 += FindMax(a,true);
		//	otrCount--;
		//}
		//cout << ans;

		int ans2 = 0;
		while(otrCount > 0)
		{
			ans += FindMin(a,true);
			otrCount--;
		}
		while(polCount > 0)
		{
			ans2 += FindMax(a,false);
			polCount--;
		}
		//if(ans1 > ans2)
		//	cout << ans1;
		//else
		//	cout << ans2;
		cout << ans2;

	}
}
void Parse(string& str)
{
	int s = str.size();
	bool minus = false;
	for(int i = 0; i < s; i++)
	{
		char ch = str[i];
		summand sd;
		if(ch == '-')
		{
			//vec.push_back(sd);
			minus = true;
		}
		else if(isdigit(ch))
		{
			string koef;
			koef += ch;
			while(i < str.size() - 1 && isdigit(ch))
			{
				i++;
				ch = str[i];
				if(isdigit(ch))
				{
					koef += ch;
				}
				else
					i--;
			}
			int tens = 1;
			for(int i = 0; i < koef.size() - 1; i++)
			{
				tens *= 10;
			}
			int koef2 = 0;
			for(int i = 0; i < koef.size(); i++)
			{
				char ch2 = koef[i];
				int t = (ch2 - '0') * tens;
				tens /= 10;
				koef2 += t;
			}
			if(minus)
				koef2 = (-1)*koef2;
			sd.koef = koef2;
			//cout << "k \n";
			//cout << koef2;
			i++; // *
			i++;
			string incr;
			if(isalpha(char(str[i])))
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p-1;
			}
			else if((char)str[i] == '+')
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p - 1;
				if(i+1 < str.size() && i+2 < str.size() && ((char)str[i+1] == '+' && (char)str[i+2] == '+'))
				{
					int p = 1;
					while(p <= 2)
					{
						incr += str[i + p++];
					}
					i = i + p-1;
				}
			}
			sd.incr = incr;
			//cout << incr;
			vec.push_back(sd);
			minus = false;

		}
		else if (isalpha(ch))
		{
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
		else if(ch == '+')
		{
			if(isalpha((char)str[i+1]) || isdigit((char)str[i+1]) || (str[i+1] == '+' && str[i+2] =='+'))
			{
				//vec.push_back(sd);
				continue;
			}
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			if(i+1 < str.size() && (char)str[i+1] == '+')
			{
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p;
			}
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
	}

	//cout << endl;
	//for(int i = 0; i < vec.size(); i++)
		//cout << vec[i].incr << " " << vec[i].koef << endl;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	int a;
	cin >> a;
	string str;
	cin >> str;
	Parse(str);
	Check(a);
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

//int main()
//{
//	int x1, y1, z1;
//	cin >> x1 >> y1 >> z1;
//	int x2, y2, z2;
//	cin >> x2 >> y2 >> z2;
//	if(abs(x1-x2)+abs(y1-y2) + abs(z1-z2) == 3)
//		cout << "NO";
//	else
//		cout << "YES";
//	return 0;
//}
//int main()
//{
//	int n;
//	cin >> n;
//	vector< vector<string > > vec;
//	vec.resize(n - 1);
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i].resize(n-1);
//	}
//
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i][0] = (i + 1) + '0';
//		vec[0][i] = (i + 1)  + '0';
//	}
//	for(int i = 1; i < n -1; i++)
//	{
//		for(int j = 1; j < n -1; j++)
//		{
//			vector<char> t;
//			const char* ch1 = vec[i][0].c_str();
//			char ch11 = ch1[0];
//			int p1 =  ch11 - '0';
//
//			const char* ch2 = vec[0][j].c_str();
//			char ch22 = ch2[0];
//			int p2 =  ch22 - '0';
//
//			int temp = p1 * p2;
//			while(temp > 0)
//			{
//
//				t.push_back((temp % n) + '0');
//				temp /= n;
//			}
//			reverse(t.begin(), t.end());
//			for(int p = 0; p < t.size(); p++)
//			{
//				vec[i][j] += t[p];
//			}
//		}
//	}
//	for(int i = 0; i < n - 1; i++)
//	{
//		for(int j = 0; j < n - 1 ; j++)
//			cout << vec[i][j] << " ";
//		cout << endl;
//	}
//	return 0;
////}
struct summand
{
	int koef;
	string incr;
	bool used;
};
vector<summand> vec;
int FindMax2(int& a)
{
	int max = -100*100*100;
	int maxInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = -100*100*100;
		if(vec[i].used == 1 && vec[i].koef < 0)
		{
			temp = vec[i].koef;
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		if(max < temp)
		{
			max = temp;
			maxInd = i;
		}
	}
	vec[maxInd].used = 0;
	if(vec[maxInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	return max;
}
int FindMin2(int& a)
{
	int min = 100*100*100;
	int minInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = 100*100*100;
		if(vec[i].used == 1 && vec[i].koef > 0)
		{
			temp = vec[i].koef;
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		if(min > temp)
		{
			min = temp;
			minInd = i;
		}
	}
	vec[minInd].used = 0;
	if(vec[minInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	return min;
}
int FindMaxKoef(int& a)
{
	int max = -100*100*100;
	int maxInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		if(vec[i].koef > max && vec[i].used == 1)
		{
			max = vec[i].koef;
			maxInd = i;
		}
	}
	int temp = max;
	if(vec[maxInd].incr.size() == 3)
	{
		if(vec[maxInd].incr[0] == '+')
		{
			//a++;
			temp *= a + 1;
		}
		else
		{
			temp *=a;
			//a++;
		}
	}
	//else
	//{
	//	//a++;
	//	temp *=a+ 1;
	//	temp++;
	//}
	vec[maxInd].used = 0;
	if(vec[maxInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	return temp;
}
int FindMinKoef(int& a)
{
	int min = 100*100*100;
	int minInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		if(vec[i].koef < min && vec[i].used == 1)
		{
			min = vec[i].koef;
			minInd = i;
		}
	}
	int temp = min;
	if(vec[minInd].incr.size() == 3)
	{
		if(vec[minInd].incr[0] == '+')
		{
			//a++;
			temp *= a + 1;
		}
		else
		{
			temp *=a;
			//a++;
		}
	}
	//else
	//{
	//	//a++;
	//	temp *=a+ 1;
	//	temp++;
	//}
	vec[minInd].used = 0;
	if(vec[minInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	return temp;
}
void Check(int a)
{
	int otrCount = 0;
	int polCount = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		vec[i].used = 1;
		if(vec[i].koef < 0)
			otrCount++;
		else
			polCount++;
	}
        int ans = 0;
        while(otrCount > 0)
        {
                ans += FindMax2(a);
				//ans +=FindMinKoef(a);
                otrCount--;
        }
    //    //cout << ans;
        while(polCount > 0)
        {
                ans += FindMin2(a);
				//ans += FindMinKoef(a);
                polCount--;
        }
        cout << ans;
}
void Parse(string& str)
{
	int s = str.size();
	bool minus = false;
	for(int i = 0; i < s; i++)
	{
		char ch = str[i];
		summand sd;
		if(ch == '-')
		{
			//vec.push_back(sd);
			minus = true;
		}
		else if(isdigit(ch))
		{
			string koef;
			koef += ch;
			while(i < str.size() - 1 && isdigit(ch))
			{
				i++;
				ch = str[i];
				if(isdigit(ch))
				{
					koef += ch;
				}
				else
					i--;
			}
			int tens = 1;
			for(int i = 0; i < koef.size() - 1; i++)
			{
				tens *= 10;
			}
			int koef2 = 0;
			for(int i = 0; i < koef.size(); i++)
			{
				char ch2 = koef[i];
				int t = (ch2 - '0') * tens;
				tens /= 10;
				koef2 += t;
			}
			if(minus)
				koef2 = (-1)*koef2;
			sd.koef = koef2;
			//cout << "k \n";
			//cout << koef2;
			i++; // *
			i++;
			string incr;
			if(isalpha(char(str[i])))
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p-1;
			}
			else if((char)str[i] == '+')
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p - 1;
			}
			sd.incr = incr;
			//cout << incr;
			vec.push_back(sd);
			minus = false;

		}
		else if (isalpha(ch))
		{
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
		else if(ch == '+')
		{
			if(isalpha((char)str[i+1]) || isdigit((char)str[i+1]) || (str[i+1] == '+' && str[i+2] =='+'))
			{
				//vec.push_back(sd);
				continue;
			}
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
	}

	//cout << endl;
	//for(int i = 0; i < vec.size(); i++)
	//	cout << vec[i].incr << " " << vec[i].koef << endl;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	int a;
	cin >> a;
	string str;
	cin >> str;
	Parse(str);
	Check(a);
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

//int main()
//{
//	int x1, y1, z1;
//	cin >> x1 >> y1 >> z1;
//	int x2, y2, z2;
//	cin >> x2 >> y2 >> z2;
//	if(abs(x1-x2)+abs(y1-y2) + abs(z1-z2) == 3)
//		cout << "NO";
//	else
//		cout << "YES";
//	return 0;
//}
//int main()
//{
//	int n;
//	cin >> n;
//	vector< vector<string > > vec;
//	vec.resize(n - 1);
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i].resize(n-1);
//	}
//
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i][0] = (i + 1) + '0';
//		vec[0][i] = (i + 1)  + '0';
//	}
//	for(int i = 1; i < n -1; i++)
//	{
//		for(int j = 1; j < n -1; j++)
//		{
//			vector<char> t;
//			const char* ch1 = vec[i][0].c_str();
//			char ch11 = ch1[0];
//			int p1 =  ch11 - '0';
//
//			const char* ch2 = vec[0][j].c_str();
//			char ch22 = ch2[0];
//			int p2 =  ch22 - '0';
//
//			int temp = p1 * p2;
//			while(temp > 0)
//			{
//
//				t.push_back((temp % n) + '0');
//				temp /= n;
//			}
//			reverse(t.begin(), t.end());
//			for(int p = 0; p < t.size(); p++)
//			{
//				vec[i][j] += t[p];
//			}
//		}
//	}
//	for(int i = 0; i < n - 1; i++)
//	{
//		for(int j = 0; j < n - 1 ; j++)
//			cout << vec[i][j] << " ";
//		cout << endl;
//	}
//	return 0;
////}
struct summand
{
	int koef;
	string incr;
	bool used;
};
vector<summand> vec;
int FindMax2(int& a)
{
	int max = -100*100*100;
	int maxInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = -100*100*100;
		if(vec[i].used == 1 && vec[i].koef < 0)
		{
			temp = vec[i].koef;
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		if(max < temp)
		{
			max = temp;
			maxInd = i;
		}
	}
	vec[maxInd].used = 0;
	if(vec[maxInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	return max;
}
int FindMin2(int& a)
{
	int min = 100*100*100;
	int minInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = 100*100*100;
		if(vec[i].used == 1 && vec[i].koef > 0)
		{
			temp = vec[i].koef;
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		if(min > temp)
		{
			min = temp;
			minInd = i;
		}
	}
	vec[minInd].used = 0;
	if(vec[minInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	return min;
}
int FindMaxKoef(int& a)
{
	int max = -100*100*100;
	int maxInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		if(vec[i].koef > max && vec[i].used == 1)
		{
			max = vec[i].koef;
			maxInd = i;
		}
	}
	int temp = max;
	if(vec[maxInd].incr.size() == 3)
	{
		if(vec[maxInd].incr[0] == '+')
		{
			//a++;
			temp *= a + 1;
		}
		else
		{
			temp *=a;
			//a++;
		}
	}
	//else
	//{
	//	//a++;
	//	temp *=a+ 1;
	//	temp++;
	//}
	vec[maxInd].used = 0;
	if(vec[maxInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	return temp;
}
int FindMinKoef(int& a)
{
	int min = 100*100*100;
	int minInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		if(vec[i].koef < min && vec[i].used == 1)
		{
			min = vec[i].koef;
			minInd = i;
		}
	}
	int temp = min;
	if(vec[minInd].incr.size() == 3)
	{
		if(vec[minInd].incr[0] == '+')
		{
			//a++;
			temp *= a + 1;
		}
		else
		{
			temp *=a;
			//a++;
		}
	}
	//else
	//{
	//	//a++;
	//	temp *=a+ 1;
	//	temp++;
	//}
	vec[minInd].used = 0;
	if(vec[minInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	return temp;
}
void Check(int a)
{
	int otrCount = 0;
	int polCount = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		vec[i].used = 1;
		if(vec[i].koef < 0)
			otrCount++;
		else
			polCount++;
	}
        int ans = 0;
    //    while(otrCount > 0)
    //    {
    //            //ans += FindMax2(a);
				//ans +=FindMinKoef(a);
    //            otrCount--;
    //    }
    //    //cout << ans;
        while(polCount + otrCount > 0)
        {
                //ans += FindMin2(a);
				ans += FindMinKoef(a);
                polCount--;
        }
        cout << ans;
}
void Parse(string& str)
{
	int s = str.size();
	bool minus = false;
	for(int i = 0; i < s; i++)
	{
		char ch = str[i];
		summand sd;
		if(ch == '-')
		{
			//vec.push_back(sd);
			minus = true;
		}
		else if(isdigit(ch))
		{
			string koef;
			koef += ch;
			while(i < str.size() - 1 && isdigit(ch))
			{
				i++;
				ch = str[i];
				if(isdigit(ch))
				{
					koef += ch;
				}
				else
					i--;
			}
			int tens = 1;
			for(int i = 0; i < koef.size() - 1; i++)
			{
				tens *= 10;
			}
			int koef2 = 0;
			for(int i = 0; i < koef.size(); i++)
			{
				char ch2 = koef[i];
				int t = (ch2 - '0') * tens;
				tens /= 10;
				koef2 += t;
			}
			if(minus)
				koef2 = (-1)*koef2;
			sd.koef = koef2;
			//cout << "k \n";
			//cout << koef2;
			i++; // *
			i++;
			string incr;
			if(isalpha(char(str[i])))
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p-1;
			}
			else if((char)str[i] == '+')
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p - 1;
				//if(i+1 < str.size() && i+2 < str.size() && ((char)str[i+1] == '+' && (char)str[i+2] == '+'))
				//{
				//	int p = 1;
				//	while(p <= 2)
				//	{
				//		incr += str[i + p++];
				//	}
				//	i = i + p-1;
				//}
			}
			sd.incr = incr;
			//cout << incr;
			vec.push_back(sd);
			minus = false;

		}
		else if (isalpha(ch))
		{
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
		else if(ch == '+')
		{
			if(isalpha((char)str[i+1]) || isdigit((char)str[i+1]) || (str[i+1] == '+' && str[i+2] =='+'))
			{
				//vec.push_back(sd);
				continue;
			}
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			//if(i+1 < str.size() && (char)str[i+1] == '+')
			//{
			//	int p = 1;
			//	while(p <= 2)
			//	{
			//		incr += str[i + p++];
			//	}
			//	i = i + p;
			//}
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
	}

	//cout << endl;
	//for(int i = 0; i < vec.size(); i++)
	//	cout << vec[i].incr << " " << vec[i].koef << endl;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	int a;
	cin >> a;
	string str;
	cin >> str;
	Parse(str);
	Check(a);
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

//int main()
//{
//	int x1, y1, z1;
//	cin >> x1 >> y1 >> z1;
//	int x2, y2, z2;
//	cin >> x2 >> y2 >> z2;
//	if(abs(x1-x2)+abs(y1-y2) + abs(z1-z2) == 3)
//		cout << "NO";
//	else
//		cout << "YES";
//	return 0;
//}
//int main()
//{
//	int n;
//	cin >> n;
//	vector< vector<string > > vec;
//	vec.resize(n - 1);
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i].resize(n-1);
//	}
//
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i][0] = (i + 1) + '0';
//		vec[0][i] = (i + 1)  + '0';
//	}
//	for(int i = 1; i < n -1; i++)
//	{
//		for(int j = 1; j < n -1; j++)
//		{
//			vector<char> t;
//			const char* ch1 = vec[i][0].c_str();
//			char ch11 = ch1[0];
//			int p1 =  ch11 - '0';
//
//			const char* ch2 = vec[0][j].c_str();
//			char ch22 = ch2[0];
//			int p2 =  ch22 - '0';
//
//			int temp = p1 * p2;
//			while(temp > 0)
//			{
//
//				t.push_back((temp % n) + '0');
//				temp /= n;
//			}
//			reverse(t.begin(), t.end());
//			for(int p = 0; p < t.size(); p++)
//			{
//				vec[i][j] += t[p];
//			}
//		}
//	}
//	for(int i = 0; i < n - 1; i++)
//	{
//		for(int j = 0; j < n - 1 ; j++)
//			cout << vec[i][j] << " ";
//		cout << endl;
//	}
//	return 0;
////}
struct summand
{
	int koef;
	string incr;
	bool used;
};
vector<summand> vec;
int FindMin(int& a, bool fl)
{
	int min = 100*100*100;
	int minInd =0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = 100*100*100;
		if(!fl && vec[i].koef > 0 && vec[i].used == 1)
		{
			temp = vec[i].koef;
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a+1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+1;
				temp++;
			}
		}
		else if(fl && vec[i].koef < 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a+1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+1;
				temp++;
			}
		}
		if(temp < min)
		{
			min = temp;
			minInd = i;
		}
	}
	vec[minInd].used = 0;
	if(vec[minInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	if(fl)
		return -min;
	else
		return min;
}
int FindMax(int& a, bool fl)
{
	int max = -100*100*100;
	int maxInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = -100*100*100;
		if(fl && vec[i].koef < 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		else if(!fl && vec[i].koef > 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		if(temp > max)
		{
			max = temp;
			maxInd = i;
		}
	}
	vec[maxInd].used = 0;
	if(vec[maxInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	if(fl)
		return -max;
	else
		return max;
}
int cmp(summand a1, summand a2)
{
	if(a1.koef < a2.koef)
		return 1;
	else if(a1.koef > a2.koef)
		return -1;
	else
		return 0;
}
void Check(int a)
{
	int otrCount = 0;
	int polCount = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		vec[i].used = 1;
		if(vec[i].koef < 0)
			otrCount++;
		else
			polCount++;
	}
	int ans = 0;
	if(a >= 0)
	{
		while(otrCount > 0)
		{
			ans += FindMax(a,true);
			otrCount--;
		}
		//cout << ans;
		while(polCount > 0)
		{
			ans += FindMin(a,false);
			polCount--;
		}
			cout << ans;

	}
	else
	{
		int tempA = a;
		int ans1 = 0;
		while(polCount > 0)
		{
			ans1 += FindMin(a,false);
			polCount--;
		}
		while(otrCount > 0)
		{
			ans1 += FindMax(a,true);
			otrCount--;
		}
		//cout << ans;

		int ans2 = 0;
		while(otrCount > 0)
		{
			ans += FindMin(a,true);
			otrCount--;
		}
		while(polCount > 0)
		{
			ans2 += FindMax(a,false);
			polCount--;
		}
		if(ans1 > ans2)
			cout << ans1;
		else
			cout << ans2;
		//cout << ans1;

	}
}
void Parse(string& str)
{
	int s = str.size();
	bool minus = false;
	for(int i = 0; i < s; i++)
	{
		char ch = str[i];
		summand sd;
		if(ch == '-')
		{
			//vec.push_back(sd);
			minus = true;
		}
		else if(isdigit(ch))
		{
			string koef;
			koef += ch;
			while(i < str.size() - 1 && isdigit(ch))
			{
				i++;
				ch = str[i];
				if(isdigit(ch))
				{
					koef += ch;
				}
				else
					i--;
			}
			int tens = 1;
			for(int i = 0; i < koef.size() - 1; i++)
			{
				tens *= 10;
			}
			int koef2 = 0;
			for(int i = 0; i < koef.size(); i++)
			{
				char ch2 = koef[i];
				int t = (ch2 - '0') * tens;
				tens /= 10;
				koef2 += t;
			}
			if(minus)
				koef2 = (-1)*koef2;
			sd.koef = koef2;
			//cout << "k \n";
			//cout << koef2;
			i++; // *
			i++;
			string incr;
			if(isalpha(char(str[i])))
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p-1;
			}
			else if((char)str[i] == '+')
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p - 1;
				if(i+1 < str.size() && i+2 < str.size() && ((char)str[i+1] == '+' && (char)str[i+2] == '+'))
				{
					int p = 1;
					while(p <= 2)
					{
						incr += str[i + p++];
					}
					i = i + p-1;
				}
			}
			sd.incr = incr;
			//cout << incr;
			vec.push_back(sd);
			minus = false;

		}
		else if (isalpha(ch))
		{
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
		else if(ch == '+')
		{
			if(isalpha((char)str[i+1]) || isdigit((char)str[i+1]) || (str[i+1] == '+' && str[i+2] =='+'))
			{
				//vec.push_back(sd);
				continue;
			}
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			if(i+1 < str.size() && (char)str[i+1] == '+')
			{
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p;
			}
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
	}

	//cout << endl;
	//for(int i = 0; i < vec.size(); i++)
		//cout << vec[i].incr << " " << vec[i].koef << endl;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	int a;
	cin >> a;
	string str;
	cin >> str;
	Parse(str);
	Check(a);
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

//int main()
//{
//	int x1, y1, z1;
//	cin >> x1 >> y1 >> z1;
//	int x2, y2, z2;
//	cin >> x2 >> y2 >> z2;
//	if(abs(x1-x2)+abs(y1-y2) + abs(z1-z2) == 3)
//		cout << "NO";
//	else
//		cout << "YES";
//	return 0;
//}
//int main()
//{
//	int n;
//	cin >> n;
//	vector< vector<string > > vec;
//	vec.resize(n - 1);
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i].resize(n-1);
//	}
//
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i][0] = (i + 1) + '0';
//		vec[0][i] = (i + 1)  + '0';
//	}
//	for(int i = 1; i < n -1; i++)
//	{
//		for(int j = 1; j < n -1; j++)
//		{
//			vector<char> t;
//			const char* ch1 = vec[i][0].c_str();
//			char ch11 = ch1[0];
//			int p1 =  ch11 - '0';
//
//			const char* ch2 = vec[0][j].c_str();
//			char ch22 = ch2[0];
//			int p2 =  ch22 - '0';
//
//			int temp = p1 * p2;
//			while(temp > 0)
//			{
//
//				t.push_back((temp % n) + '0');
//				temp /= n;
//			}
//			reverse(t.begin(), t.end());
//			for(int p = 0; p < t.size(); p++)
//			{
//				vec[i][j] += t[p];
//			}
//		}
//	}
//	for(int i = 0; i < n - 1; i++)
//	{
//		for(int j = 0; j < n - 1 ; j++)
//			cout << vec[i][j] << " ";
//		cout << endl;
//	}
//	return 0;
////}
struct summand
{
	int koef;
	string incr;
	bool used;
};
vector<summand> vec;
int FindMin(int& a, bool fl)
{
	int min = 100*100*100;
	int minInd =0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = 100*100*100;
		if(!fl && vec[i].koef > 0 && vec[i].used == 1)
		{
			temp = vec[i].koef;
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a+1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+1;
				temp++;
			}
		}
		else if(fl && vec[i].koef < 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a+1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+1;
				temp++;
			}
		}
		if(temp < min)
		{
			min = temp;
			minInd = i;
		}
	}
	vec[minInd].used = 0;
	if(vec[minInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	if(fl)
		return -min;
	else
		return min;
}
int FindMax(int& a, bool fl)
{
	int max = -100*100*100;
	int maxInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = -100*100*100;
		if(fl && vec[i].koef < 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		else if(!fl && vec[i].koef > 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		if(temp > max)
		{
			max = temp;
			maxInd = i;
		}
	}
	vec[maxInd].used = 0;
	if(vec[maxInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	if(fl)
		return -max;
	else
		return max;
}
int cmp(summand a1, summand a2)
{
	if(a1.koef < a2.koef)
		return 1;
	else if(a1.koef > a2.koef)
		return -1;
	else
		return 0;
}
void Check(int a)
{
	int otrCount = 0;
	int polCount = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		vec[i].used = 1;
		if(vec[i].koef < 0)
			otrCount++;
		else
			polCount++;
	}
	int ans = 0;
	if(a >= 0)
	{
		while(otrCount > 0)
		{
			ans += FindMax(a,true);
			otrCount--;
		}
		//cout << ans;
		while(polCount > 0)
		{
			ans += FindMin(a,false);
			polCount--;
		}
			cout << ans;

	}
	else
	{
		int tempA = a;
		int ans1 = 0;
		while(polCount > 0)
		{
			ans1 += FindMin(a,false);
			polCount--;
		}
		while(otrCount > 0)
		{
			ans1 += FindMax(a,true);
			otrCount--;
		}
		//cout << ans;

		//int ans2 = 0;
		//while(otrCount > 0)
		//{
		//	ans += FindMin(a,true);
		//	otrCount--;
		//}
		//while(polCount > 0)
		//{
		//	ans2 += FindMax(a,false);
		//	polCount--;
		//}
		//if(ans1 > ans2)
		//	cout << ans1;
		//else
		//	cout << ans2;
		cout << ans1;

	}
}
void Parse(string& str)
{
	int s = str.size();
	bool minus = false;
	for(int i = 0; i < s; i++)
	{
		char ch = str[i];
		summand sd;
		if(ch == '-')
		{
			//vec.push_back(sd);
			minus = true;
		}
		else if(isdigit(ch))
		{
			string koef;
			koef += ch;
			while(i < str.size() - 1 && isdigit(ch))
			{
				i++;
				ch = str[i];
				if(isdigit(ch))
				{
					koef += ch;
				}
				else
					i--;
			}
			int tens = 1;
			for(int i = 0; i < koef.size() - 1; i++)
			{
				tens *= 10;
			}
			int koef2 = 0;
			for(int i = 0; i < koef.size(); i++)
			{
				char ch2 = koef[i];
				int t = (ch2 - '0') * tens;
				tens /= 10;
				koef2 += t;
			}
			if(minus)
				koef2 = (-1)*koef2;
			sd.koef = koef2;
			//cout << "k \n";
			//cout << koef2;
			i++; // *
			i++;
			string incr;
			if(isalpha(char(str[i])))
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p-1;
			}
			else if((char)str[i] == '+')
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p - 1;
				if(i+1 < str.size() && i+2 < str.size() && ((char)str[i+1] == '+' && (char)str[i+2] == '+'))
				{
					int p = 1;
					while(p <= 2)
					{
						incr += str[i + p++];
					}
					i = i + p-1;
				}
			}
			sd.incr = incr;
			//cout << incr;
			vec.push_back(sd);
			minus = false;

		}
		else if (isalpha(ch))
		{
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
		else if(ch == '+')
		{
			if(isalpha((char)str[i+1]) || isdigit((char)str[i+1]) || (str[i+1] == '+' && str[i+2] =='+'))
			{
				//vec.push_back(sd);
				continue;
			}
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			if(i+1 < str.size() && (char)str[i+1] == '+')
			{
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p;
			}
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
	}

	//cout << endl;
	//for(int i = 0; i < vec.size(); i++)
		//cout << vec[i].incr << " " << vec[i].koef << endl;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	int a;
	cin >> a;
	string str;
	cin >> str;
	Parse(str);
	Check(a);
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

//int main()
//{
//	int x1, y1, z1;
//	cin >> x1 >> y1 >> z1;
//	int x2, y2, z2;
//	cin >> x2 >> y2 >> z2;
//	if(abs(x1-x2)+abs(y1-y2) + abs(z1-z2) == 3)
//		cout << "NO";
//	else
//		cout << "YES";
//	return 0;
//}
//int main()
//{
//	int n;
//	cin >> n;
//	vector< vector<string > > vec;
//	vec.resize(n - 1);
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i].resize(n-1);
//	}
//
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i][0] = (i + 1) + '0';
//		vec[0][i] = (i + 1)  + '0';
//	}
//	for(int i = 1; i < n -1; i++)
//	{
//		for(int j = 1; j < n -1; j++)
//		{
//			vector<char> t;
//			const char* ch1 = vec[i][0].c_str();
//			char ch11 = ch1[0];
//			int p1 =  ch11 - '0';
//
//			const char* ch2 = vec[0][j].c_str();
//			char ch22 = ch2[0];
//			int p2 =  ch22 - '0';
//
//			int temp = p1 * p2;
//			while(temp > 0)
//			{
//
//				t.push_back((temp % n) + '0');
//				temp /= n;
//			}
//			reverse(t.begin(), t.end());
//			for(int p = 0; p < t.size(); p++)
//			{
//				vec[i][j] += t[p];
//			}
//		}
//	}
//	for(int i = 0; i < n - 1; i++)
//	{
//		for(int j = 0; j < n - 1 ; j++)
//			cout << vec[i][j] << " ";
//		cout << endl;
//	}
//	return 0;
////}
struct summand
{
	int koef;
	string incr;
	bool used;
};
vector<summand> vec;
int FindMin(int& a, bool fl)
{
	int min = 100*100*100;
	int minInd =0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = 100*100*100;
		if(!fl && vec[i].koef > 0 && vec[i].used == 1)
		{
			temp = vec[i].koef;
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a+1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+1;
				temp++;
			}
		}
		else if(fl && vec[i].koef < 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a+1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+1;
				temp++;
			}
		}
		if(temp < min)
		{
			min = temp;
			minInd = i;
		}
	}
	vec[minInd].used = 0;
	if(vec[minInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	if(fl)
		return -min;
	else
		return min;
}
int FindMax(int& a, bool fl)
{
	int max = -100*100*100;
	int maxInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = -100*100*100;
		if(fl && vec[i].koef < 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		else if(!fl && vec[i].koef > 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		if(temp > max)
		{
			max = temp;
			maxInd = i;
		}
	}
	vec[maxInd].used = 0;
	if(vec[maxInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	if(fl)
		return -max;
	else
		return max;
}
int cmp(summand a1, summand a2)
{
	if(a1.koef < a2.koef)
		return 1;
	else if(a1.koef > a2.koef)
		return -1;
	else
		return 0;
}
void Check(int a)
{
	int otrCount = 0;
	int polCount = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		vec[i].used = 1;
		if(vec[i].koef < 0)
			otrCount++;
		else
			polCount++;
	}
	int ans = 0;
	if(a >= 0)
	{
		while(otrCount > 0)
		{
			ans += FindMax(a,true);
			otrCount--;
		}
		//cout << ans;
		while(polCount > 0)
		{
			ans += FindMin(a,false);
			polCount--;
		}
			cout << ans;

	}
	else
	{
		int tempA = a;
		int ans1 = 0;
		while(polCount > 0)
		{
			ans1 += FindMin(a,false);
			polCount--;
		}
		while(otrCount > 0)
		{
			ans1 += FindMax(a,true);
			otrCount--;
		}
		//cout << ans;

		int ans2 = 0;
		while(otrCount > 0)
		{
			ans += FindMin(a,true);
			otrCount--;
		}
		while(polCount > 0)
		{
			ans2 += FindMax(a,false);
			polCount--;
		}
		if(ans1 > ans2)
			cout << ans1;
		else
			cout << ans2;
		cout << ans1;

	}
}
void Parse(string& str)
{
	int s = str.size();
	bool minus = false;
	for(int i = 0; i < s; i++)
	{
		char ch = str[i];
		summand sd;
		if(ch == '-')
		{
			//vec.push_back(sd);
			minus = true;
		}
		else if(isdigit(ch))
		{
			string koef;
			koef += ch;
			while(i < str.size() - 1 && isdigit(ch))
			{
				i++;
				ch = str[i];
				if(isdigit(ch))
				{
					koef += ch;
				}
				else
					i--;
			}
			int tens = 1;
			for(int i = 0; i < koef.size() - 1; i++)
			{
				tens *= 10;
			}
			int koef2 = 0;
			for(int i = 0; i < koef.size(); i++)
			{
				char ch2 = koef[i];
				int t = (ch2 - '0') * tens;
				tens /= 10;
				koef2 += t;
			}
			if(minus)
				koef2 = (-1)*koef2;
			sd.koef = koef2;
			//cout << "k \n";
			//cout << koef2;
			i++; // *
			i++;
			string incr;
			if(isalpha(char(str[i])))
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p-1;
			}
			else if((char)str[i] == '+')
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p - 1;
				if(i+1 < str.size() && i+2 < str.size() && ((char)str[i+1] == '+' && (char)str[i+2] == '+'))
				{
					int p = 1;
					while(p <= 2)
					{
						incr += str[i + p++];
					}
					i = i + p-1;
				}
			}
			sd.incr = incr;
			//cout << incr;
			vec.push_back(sd);
			minus = false;

		}
		else if (isalpha(ch))
		{
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
		else if(ch == '+')
		{
			if(isalpha((char)str[i+1]) || isdigit((char)str[i+1]) || (str[i+1] == '+' && str[i+2] =='+'))
			{
				//vec.push_back(sd);
				continue;
			}
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			if(i+1 < str.size() && (char)str[i+1] == '+')
			{
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p;
			}
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
	}

	//cout << endl;
	//for(int i = 0; i < vec.size(); i++)
		//cout << vec[i].incr << " " << vec[i].koef << endl;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	int a;
	cin >> a;
	string str;
	cin >> str;
	Parse(str);
	Check(a);
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

//int main()
//{
//	int x1, y1, z1;
//	cin >> x1 >> y1 >> z1;
//	int x2, y2, z2;
//	cin >> x2 >> y2 >> z2;
//	if(abs(x1-x2)+abs(y1-y2) + abs(z1-z2) == 3)
//		cout << "NO";
//	else
//		cout << "YES";
//	return 0;
//}
//int main()
//{
//	int n;
//	cin >> n;
//	vector< vector<string > > vec;
//	vec.resize(n - 1);
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i].resize(n-1);
//	}
//
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i][0] = (i + 1) + '0';
//		vec[0][i] = (i + 1)  + '0';
//	}
//	for(int i = 1; i < n -1; i++)
//	{
//		for(int j = 1; j < n -1; j++)
//		{
//			vector<char> t;
//			const char* ch1 = vec[i][0].c_str();
//			char ch11 = ch1[0];
//			int p1 =  ch11 - '0';
//
//			const char* ch2 = vec[0][j].c_str();
//			char ch22 = ch2[0];
//			int p2 =  ch22 - '0';
//
//			int temp = p1 * p2;
//			while(temp > 0)
//			{
//
//				t.push_back((temp % n) + '0');
//				temp /= n;
//			}
//			reverse(t.begin(), t.end());
//			for(int p = 0; p < t.size(); p++)
//			{
//				vec[i][j] += t[p];
//			}
//		}
//	}
//	for(int i = 0; i < n - 1; i++)
//	{
//		for(int j = 0; j < n - 1 ; j++)
//			cout << vec[i][j] << " ";
//		cout << endl;
//	}
//	return 0;
////}
struct summand
{
	int koef;
	string incr;
	bool used;
};
vector<summand> vec;
int FindMin(int& a, bool fl)
{
	int min = 100*100*100;
	int minInd =0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = 100*100*100;
		if(!fl && vec[i].koef > 0 && vec[i].used == 1)
		{
			temp = vec[i].koef;
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a+1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+1;
				temp++;
			}
		}
		else if(fl && vec[i].koef < 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a+1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+1;
				temp++;
			}
		}
		if(temp < min)
		{
			min = temp;
			minInd = i;
		}
	}
	vec[minInd].used = 0;
	if(vec[minInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	if(fl)
		return -min;
	else
		return min;
}
int FindMax(int& a, bool fl)
{
	int max = -100*100*100;
	int maxInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = -100*100*100;
		if(fl && vec[i].koef < 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		else if(!fl && vec[i].koef > 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		if(temp > max)
		{
			max = temp;
			maxInd = i;
		}
	}
	vec[maxInd].used = 0;
	if(vec[maxInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	if(fl)
		return -max;
	else
		return max;
}
int cmp(summand a1, summand a2)
{
	if(a1.koef < a2.koef)
		return 1;
	else if(a1.koef > a2.koef)
		return -1;
	else
		return 0;
}
void Check(int a)
{
	int otrCount = 0;
	int polCount = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		vec[i].used = 1;
		if(vec[i].koef < 0)
			otrCount++;
		else
			polCount++;
	}
        int ans = 0;
        if(a >= 0)
        {
                while(otrCount > 0)
                {
                        ans += FindMax(a,true);
                        otrCount--;
                }
                //cout << ans;
                while(polCount > 0)
                {
                        ans += FindMin(a,false);
                        polCount--;
                }
        }
        else
        {       while(otrCount > 0)
                {
                        ans += FindMin(a,true);
                        otrCount--;
                }
                while(polCount > 0)
                {
                        ans += FindMax(a,false);
                        polCount--;
                }

        }
        cout << ans;
}
void Parse(string& str)
{
	int s = str.size();
	bool minus = false;
	for(int i = 0; i < s; i++)
	{
		char ch = str[i];
		summand sd;
		if(ch == '-')
		{
			//vec.push_back(sd);
			minus = true;
		}
		else if(isdigit(ch))
		{
			string koef;
			koef += ch;
			while(i < str.size() - 1 && isdigit(ch))
			{
				i++;
				ch = str[i];
				if(isdigit(ch))
				{
					koef += ch;
				}
				else
					i--;
			}
			int tens = 1;
			for(int i = 0; i < koef.size() - 1; i++)
			{
				tens *= 10;
			}
			int koef2 = 0;
			for(int i = 0; i < koef.size(); i++)
			{
				char ch2 = koef[i];
				int t = (ch2 - '0') * tens;
				tens /= 10;
				koef2 += t;
			}
			if(minus)
				koef2 = (-1)*koef2;
			sd.koef = koef2;
			//cout << "k \n";
			//cout << koef2;
			i++; // *
			i++;
			string incr;
			if(isalpha(char(str[i])))
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p-1;
			}
			else if((char)str[i] == '+')
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p - 1;
				if(i+1 < str.size() && i+2 < str.size() && ((char)str[i+1] == '+' && (char)str[i+2] == '+'))
				{
					int p = 1;
					while(p <= 2)
					{
						incr += str[i + p++];
					}
					i = i + p-1;
				}
			}
			sd.incr = incr;
			//cout << incr;
			vec.push_back(sd);
			minus = false;

		}
		else if (isalpha(ch))
		{
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
		else if(ch == '+')
		{
			if(isalpha((char)str[i+1]) || isdigit((char)str[i+1]) || (str[i+1] == '+' && str[i+2] =='+'))
			{
				//vec.push_back(sd);
				continue;
			}
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			if(i+1 < str.size() && (char)str[i+1] == '+')
			{
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p;
			}
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
	}

	//cout << endl;
	//for(int i = 0; i < vec.size(); i++)
		//cout << vec[i].incr << " " << vec[i].koef << endl;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	int a;
	cin >> a;
	string str;
	cin >> str;
	Parse(str);
	Check(a);
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

//int main()
//{
//	int x1, y1, z1;
//	cin >> x1 >> y1 >> z1;
//	int x2, y2, z2;
//	cin >> x2 >> y2 >> z2;
//	if(abs(x1-x2)+abs(y1-y2) + abs(z1-z2) == 3)
//		cout << "NO";
//	else
//		cout << "YES";
//	return 0;
//}
//int main()
//{
//	int n;
//	cin >> n;
//	vector< vector<string > > vec;
//	vec.resize(n - 1);
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i].resize(n-1);
//	}
//
//	for(int i = 0; i < n - 1; i++)
//	{
//		vec[i][0] = (i + 1) + '0';
//		vec[0][i] = (i + 1)  + '0';
//	}
//	for(int i = 1; i < n -1; i++)
//	{
//		for(int j = 1; j < n -1; j++)
//		{
//			vector<char> t;
//			const char* ch1 = vec[i][0].c_str();
//			char ch11 = ch1[0];
//			int p1 =  ch11 - '0';
//
//			const char* ch2 = vec[0][j].c_str();
//			char ch22 = ch2[0];
//			int p2 =  ch22 - '0';
//
//			int temp = p1 * p2;
//			while(temp > 0)
//			{
//
//				t.push_back((temp % n) + '0');
//				temp /= n;
//			}
//			reverse(t.begin(), t.end());
//			for(int p = 0; p < t.size(); p++)
//			{
//				vec[i][j] += t[p];
//			}
//		}
//	}
//	for(int i = 0; i < n - 1; i++)
//	{
//		for(int j = 0; j < n - 1 ; j++)
//			cout << vec[i][j] << " ";
//		cout << endl;
//	}
//	return 0;
////}
struct summand
{
	int koef;
	string incr;
	bool used;
};
vector<summand> vec;
int FindMin(int& a, bool fl)
{
	int min = 100*100*100;
	int minInd =0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = 100*100*100;
		if(!fl && vec[i].koef > 0 && vec[i].used == 1)
		{
			temp = vec[i].koef;
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a+1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+1;
				temp++;
			}
		}
		else if(fl && vec[i].koef < 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a+1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+1;
				temp++;
			}
		}
		if(temp < min)
		{
			min = temp;
			minInd = i;
		}
	}
	vec[minInd].used = 0;
	if(vec[minInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	if(fl)
		return -min;
	else
		return min;
}
int FindMax(int& a, bool fl)
{
	int max = -100*100*100;
	int maxInd = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		int temp = -100*100*100;
		if(fl && vec[i].koef < 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		else if(!fl && vec[i].koef > 0 && vec[i].used == 1)
		{
			temp = abs(vec[i].koef);
			if(vec[i].incr.size() == 3)
			{
				if(vec[i].incr[0] == '+')
				{
					//a++;
					temp *= a + 1;
				}
				else
				{
					temp *=a;
					//a++;
				}
			}
			else
			{
				//a++;
				temp *=a+ 1;
				temp++;
			}
		}
		if(temp > max)
		{
			max = temp;
			maxInd = i;
		}
	}
	vec[maxInd].used = 0;
	if(vec[maxInd].incr.size() == 3)
		a++;
	else
		a = a + 2;
	if(fl)
		return -max;
	else
		return max;
}
int cmp(summand a1, summand a2)
{
	if(a1.koef < a2.koef)
		return 1;
	else if(a1.koef > a2.koef)
		return -1;
	else
		return 0;
}
void Check(int a)
{
	int otrCount = 0;
	int polCount = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		vec[i].used = 1;
		if(vec[i].koef < 0)
			otrCount++;
		else
			polCount++;
	}
        int ans = 0;
        if(a >= 0)
        {
                while(otrCount > 0)
                {
                        ans += FindMax(a,true);
                        otrCount--;
                }
                //cout << ans;
                while(polCount > 0)
                {
                        ans += FindMin(a,false);
                        polCount--;
                }
        }
        else
        {
			int tempA = a;
			int ans1= 0;
			while(otrCount > 0)
                {
                        ans1 += FindMin(tempA,true);
                        otrCount--;
                }
                while(polCount > 0)
                {
                        ans1 += FindMax(tempA,false);
                        polCount--;
                }

			int tempA2 = a;
			int ans2 = 0;
			while(otrCount > 0)
                {
                        ans2 += FindMax(tempA2,true);
                        otrCount--;
                }
                //cout << ans;
                while(polCount > 0)
                {
                        ans2 += FindMin(tempA2,false);
                        polCount--;
                }
				if(ans1 > ans2)
					ans = ans1;
				else
					ans = ans2;

        }
        cout << ans;
}
void Parse(string& str)
{
	int s = str.size();
	bool minus = false;
	for(int i = 0; i < s; i++)
	{
		char ch = str[i];
		summand sd;
		if(ch == '-')
		{
			//vec.push_back(sd);
			minus = true;
		}
		else if(isdigit(ch))
		{
			string koef;
			koef += ch;
			while(i < str.size() - 1 && isdigit(ch))
			{
				i++;
				ch = str[i];
				if(isdigit(ch))
				{
					koef += ch;
				}
				else
					i--;
			}
			int tens = 1;
			for(int i = 0; i < koef.size() - 1; i++)
			{
				tens *= 10;
			}
			int koef2 = 0;
			for(int i = 0; i < koef.size(); i++)
			{
				char ch2 = koef[i];
				int t = (ch2 - '0') * tens;
				tens /= 10;
				koef2 += t;
			}
			if(minus)
				koef2 = (-1)*koef2;
			sd.koef = koef2;
			//cout << "k \n";
			//cout << koef2;
			i++; // *
			i++;
			string incr;
			if(isalpha(char(str[i])))
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p-1;
			}
			else if((char)str[i] == '+')
			{
				incr += str[i];
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p - 1;
				if(i+1 < str.size() && i+2 < str.size() && ((char)str[i+1] == '+' && (char)str[i+2] == '+'))
				{
					int p = 1;
					while(p <= 2)
					{
						incr += str[i + p++];
					}
					i = i + p-1;
				}
			}
			sd.incr = incr;
			//cout << incr;
			vec.push_back(sd);
			minus = false;

		}
		else if (isalpha(ch))
		{
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
		else if(ch == '+')
		{
			if(isalpha((char)str[i+1]) || isdigit((char)str[i+1]) || (str[i+1] == '+' && str[i+2] =='+'))
			{
				//vec.push_back(sd);
				continue;
			}
			string incr;
			incr += ch;
			int p = 1;
			while(p <= 2)
			{
				incr += str[i + p++];
			}
			i = i + p - 1;
			if(i+1 < str.size() && (char)str[i+1] == '+')
			{
				int p = 1;
				while(p <= 2)
				{
					incr += str[i + p++];
				}
				i = i + p;
			}
			//cout << incr;
			sd.incr = incr;
			if(!minus)
				sd.koef = 1;
			else
				sd.koef = -1;
			minus = false;
			vec.push_back(sd);
		}
	}

	//cout << endl;
	//for(int i = 0; i < vec.size(); i++)
		//cout << vec[i].incr << " " << vec[i].koef << endl;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	int a;
	cin >> a;
	string str;
	cin >> str;
	Parse(str);
	Check(a);
	return 0;
}