//============================================================================
// Name        : [email protected]
// Author      : LiJunLe
// Version     : Accepted
// Copyright   : http://www.codeforces.com/contest/39/problem/A
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#define M 1005
using namespace std;

string in;
int length;
int inode;

void tle() {
	while (true);
}

void re() {
	int *p = NULL; *p = 0;
}

struct Node {
	int coefficient;
	int kind; // 1:a++, 2:++a

	bool operator<(Node o) const {
		return coefficient < o.coefficient;
	}
} node[M];

void debug() {
	cout << inode << ": ";
	for (int i = 0; i < inode; i++) {
		cout << node[i].coefficient << "*";
		if (node[i].kind == 1) {
			cout << "a++ ";
		} else if (node[i].kind == 2) {
			cout << "++a ";
		} else {
			cout << "ERROR ";
		}
	}
	cout << endl;
}

int getNumber() {
	int ret = 0;
	int base = 1;
	for (; length >= 0; length--) {
		if ('0' <= in[length] && in[length] <= '9') {
			ret += base * (in[length] - '0');
			base *= 10;
		} else if (in[length] == '-') {
			ret *= -1;
			length--;
			break;
		} else if (in[length] == '+') {
			length--;
			break;
		}
	}
	return ret;
}

void getNode() {
	if (length < 0) {
		return;
	}
	if (in[length-2] == '+' && in[length-1] == '+' && in[length] == 'a') {
		node[inode].kind = 2;
	} else if (in[length-2] == 'a' && in[length-1] == '+' && in[length] == '+') {
		node[inode].kind = 1;
	}
	length -= 3;
	if (length < 0) {
		node[inode].coefficient = 1;
	} else if (in[length] == '+') {
		node[inode].coefficient = 1;
		length--;
	} else if (in[length] == '-') {
		node[inode].coefficient = -1;
		length--;
	} else if (in[length] == '*') {
		length--;
		node[inode].coefficient = getNumber();
	}
	inode++;
	getNode();
}

int main() {
	int a;
	while (scanf("%d", &a) != EOF) {
		cin >> in;
		length = in.length() - 1;
		inode = 0;
		getNode();
//		debug();
		sort(node, node + inode);
		int ans = 0;
		for (int i = 0; i < inode; i++) {
			if (node[i].kind == 1) {
				ans += node[i].coefficient * a;
				a++;
			} else if (node[i].kind == 2) {
				a++;
				ans += node[i].coefficient * a;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}