#C14175. Evaluate Mathematical Expression
Evaluate Mathematical Expression
Evaluate Mathematical Expression
You are given a string s
representing a mathematical expression which consists of non-negative integers and the operators +
and -
. Your task is to evaluate the expression and output the result as an integer.
The expression does not contain any whitespace and is guaranteed to be valid. Note that the evaluation is performed from left to right without any operator precedence beyond the given order.
For example, if the input is 3+5-2
, the output should be 6
.
inputFormat
A single line containing the mathematical expression as a string.
outputFormat
A single integer representing the result of the evaluated expression.## sample
3+5-2
6