#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <cstring>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class LostParentheses { public:
	int minResult(string e) 
	{
		int sum = 0;
		bool prevOpPlus = true;
		bool minusFound = false;
		for(int p=0,i=0; i<=e.size(); ++i)
			if( i==e.size() || e[i] == '-' )
			{
				stringstream ss;
				ss << e.substr(p, i-p);
				int num;
				ss >> num;

				sum += (prevOpPlus ? +num : -num);
				p = i+1;
				minusFound = true;
				prevOpPlus = false;
			}
			else if( e[i] == '+' )
			{
				stringstream ss;
				ss << e.substr(p, i-p);
				int num;
				ss >> num;

				sum += (prevOpPlus ? +num : -num);
				p = i+1;
				prevOpPlus = !minusFound;
			}
		return sum;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const int& Expected, const int& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, LostParentheses().minResult(e));}
int main(){

CASE(0)
	string e = "55-50+40"; 
	int _ = -35; 
END
CASE(1)
	string e = "10+20+30+40"; 
	int _ = 100; 
END
CASE(2)
	string e = "00009-00009"; 
	int _ = 0; 
END
CASE(3)
	string e = "1"; 
	int _ = 1; 
END
CASE(4)
	string e = "1-2+3"; 
	int _ = -4; 
END

}
// END CUT HERE
