public int calculate(String s) {
		int result = 0;
		Stack<Integer> stack = new Stack<Integer>();
		int operator = 1;
		int number = 0;
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			switch (c) {
			case '+':
				result += operator * number;
				number = 0;
				operator = 1;
				break;
			case '-':
				result += operator * number;
				number = 0;
				operator = -1;
				break;
			case '(':
				stack.push(result);
				stack.push(operator);
				result = 0;
				operator = 1;
				number = 0;
				break;
			case ')':
				result += operator * number;
				result *= stack.pop();
				result += stack.pop();
				number = 0;
				operator = 1;
				break;
			case ' ':
				break;
			default:
				number = number * 10 + c - '0';
				break;
			}
		}
		if (number != 0) {
			result += operator * number;
		}
		return result;
	}