# Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

# Old Magic!

You: Guess an integer number, but don’t tell me.

Your friend: Okay!

You: Now multiply it by 3.

Your friend: Okay.

You: Add 4 to it.

Your friend: Done.

You: Multiply it by 4.

Your friend: Wait… okay, done.

You: Subtract 4 from it.

Your friend: Okay!

You: Divide the number by 12.

Your friend: Wait, how did you know that this number will be divisible by 12?

You: Ha Ha Ha! Magic my friend. Just do it please.

Your friend: Okay, done.

You: What did you get?

Your friend: 50.

You: You guessed 49, right?

Your friend: Wow! You are a great magician!

You: Thanks. It’s just some mathematical trick!

After impressing your friend, you are thinking of creating a program to automate some process for yourself. The program should take a series of commands and the final number your friend got as input. You have to print the number your friend guessed. Simple and fun, right?

## Input

In the first line of input, there will be a number **N** (1 ≤ N ≤ 10) denoting the number of commands. In the next N lines there will be a command in each. The command will be any of the following 4 types:

- add x
- subtract x
- multiply x
- divide x

Where **x** is an integer. After that, in a new line there will be an integer that your friend got after all these operations. You can safely assume that after any operation, the number your friend got will be an integer and will not exceed 64-bit signed integer. You can also safely assume that your friend will always guess an integer initially.

In the input, there will be no command to multiply or divide by 0. And you can assume that all the commands are valid.

## Output

In a single line, print the integer number your friend guessed.

## Sample

Input | Output |
---|---|

5 multiply 3 add 4 multiply 4 subtract 4 divide 12 50 | 49 |

86% Solution Ratio

mdshs.shantoEarliest,

Coder_RafiFastest, 0.0s

wasimur_01Lightest, 0 B

touhidurShortest, 181B

Login to submit