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 P
and -
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 .
Input Specification
Line 1: The equation, a sequence of numbers, P
, and 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 Specification
Output one integer, the solution (right side) of the equation.
Sample Input
5 P 13 P 27 M 35 =
Sample Output
10
Comments
Ah... Time to pull out the good old snake again...
Is the reason your math teacher is a troll because she knows Python?