시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB109624855.814%

문제

Write a program that can evaluate expressions from the following roughly BNF (Backus Naur Form) grammar:

expr ::=  term | expr ‘+’ term | expr ‘-’ term
unary_op ::= ‘+’ term | ‘-’ term
term ::= ‘(’ expr ‘)’ | ‘(’ unary_op ‘)’ | literal
literal ::= [0-9]

There will be no whitespace within an expression. All expressions will consist solely of the characters (, ), +, -, and the digits 0 through 9. You may assume that all input is well-formed.

입력

The input will consist of one expression per line followed by a newline. The length of expression does not exceed 200.

There will be no blank lines in the file.

출력

For each expression, output its integer value, followed by a single newline.

예제 입력 1

1
(-2)+3
(1-(2+3))
(1-2+3)
(1-(+(2-3)))

예제 출력 1

1
1
-4
2
2