提示: 欢迎访问OurACM平台。
Problem 1505 Minimum value

Accept: 344    Submit: 529
Time Limit: 1000 mSec    Memory Limit : 32768 KB

Problem Description

An arithmetic expression is defined as a sequence of positive integers, separated by arithmetic operators: +,-,(,). Given an arithmetic expression without parentheses, you are to calculate the minimum possible value for the expression, by adding appropriate parentheses to the expression.

Input

The input contains several test cases. Each test case is a single line containing a expression.

The expression consists of only positive integers,+,-

Numbers in expression may contain leading zeroes and is within 32bit integer, the total length of the expression will not exceed 100.

Output

For each case, output an integer representing the minimum value of the expression.

Sample input

Sample Input

00009-00009 10+20+30+40 1-4+6

Sample Output

0 100 -9

Source

FOJ月赛-2007年5月

Submit  Back  Status  Discuss