You've made it to the weekend, and you're ready to sleep! While trying to fall asleep, a nagging voice repeatedly commands you to do your math homework first. Since you want to sleep as soon as possible, you decide to do the problems super quickly. But there's a problem — your math teacher thought it was a funny joke to give you tons of super easy problems. The teacher also thought it was funny to replace
+ signs with the character
- signs with the character
M. Instead of wasting your time solving each one by hand, you decide to write a program to solve them. The questions will only involve subtraction and addition, and have up to terms with all numbers greater than and less than or equal to .
Line 1: The equation, a sequence of numbers,
M. Each term will be space separated from every other term. The equation will be terminated by
=. There will be at least one term in the sequence.
Output one integer, the solution (right side) of the equation.
5 P 13 P 27 M 35 =