#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-4;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
string s; int n;
int m;
int num[200];bool ord[200][2];
char oper[200];
bool valid;
int calc(int le, int ri) {
	valid = true; int res = num[le];
	Rep1(i, le+1, ri) {
		if (oper[i - 1] == '+') {
			res += num[i];
		}
		else {
			res -= num[i];
		}
	}
	Rep1(i, le + 1, ri - 1) {
		if (ord[i][0] || ord[i][1])valid = false;
	}
	if (ri-le>0&&(ord[le][1] || ord[ri][0]))valid = false;
	return res;
}
bool chk[200][200];
P ans[200][200];
P dfs(int le, int ri) {
	if (chk[le][ri])return ans[le][ri];
	chk[le][ri] = true;
	if (le > ri)return ans[le][ri] = { 0,0 };
	P res = { mod,-mod };
	int t = calc(le, ri);
	if (valid)res = { t,t };
	if (ri - le > 0 && (ord[le][1] || ord[ri][0]))return ans[le][ri]=res;
	Rep1(i, le+1,ri) {
		if (ord[i][1])continue;
		Rep1(j, i + 1, ri-1) {
			if (ord[j][0])continue;
			//if (i == le && j == ri)continue;
			P s1 = dfs(le, i - 1),s2=dfs(i,j),s3=dfs(j+1,ri);
			if (s1.first == mod || s2.first == mod || s3.first == mod)continue;
			int mi = s1.first, ma = s1.second;
			if (oper[i - 1] == '+') {
				mi += s2.first; ma += s2.second;
			}
			else {
				mi -= s2.second; ma -= s2.first;
			}
			if (oper[j] == '+') {
				mi += s3.first; ma += s3.second;
			}
			else {
				mi -= s3.second; ma -= s3.first;
			}
			res.first = min(res.first, mi);
			res.second = max(res.second, ma);
		}
	}
	Rep1(i, le + 1, ri - 1) {
		if (ord[i][0])continue;
		P s1 = dfs(le, i), s2 = dfs(i + 1, ri);
		if (s1.first == mod || s2.first == mod)continue;
		int mi = s1.first, ma = s1.second;
		if (oper[i] == '+') {
			mi += s2.first; ma += s2.second;
		}
		else {
			mi -= s2.second; ma -= s2.first;
		}
		res.first = min(res.first, mi);
		res.second = max(res.second, ma);
	}
	Rep1(i, le + 1, ri - 1) {
		if (ord[i][1])continue;
		P s1 = dfs(le, i - 1), s2 = dfs(i, ri);
		if (s1.first == mod || s2.first == mod)continue;
		int mi = s1.first, ma = s1.second;
		if (oper[i - 1] == '+') {
			mi += s2.first; ma += s2.second;
		}
		else {
			mi -= s2.second; ma -= s2.first;
		}
		res.first = min(res.first, mi);
		res.second = max(res.second, ma);
	}
	return ans[le][ri]=res;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> s; n = s.length();
	for (int i = 0; i < n; i += 2) {
		while (s[i] == '(') {
			ord[m][0] = true; i++;
		}
		num[m] = s[i] - '0';
		while (i + 1 < n&&s[i + 1] == ')') {
			ord[m][1] = true; i++;
		}
		if (i + 1 < n) {
			oper[m] = s[i + 1];
		}
		m++;
	}
	cout << dfs(0, m - 1).second << endl;
	/*rep(i,m) {
		Rep(j, i, m) {
			cout << i << " " << j << endl;
			cout << ans[i][j].first << " " << ans[i][j].second << endl;

		}
	}
	rep(i, m) {
		cout << num[i] << endl;
	}*/
	return 0;
}
