11716 - I2P_17_EECS_MID_2_2   

Description

Probelm: Min Max (6 points)

Given a sequence of min and max operations, calculate the answer.

'M35' means max(3, 5) and the answer is 5.
'm62' means min(6, 2) and the answer is 2.

For a longer sequence such as 'M3mM42m56', it means
max( 3, min(max(4, 2), min(5, 6)))
and the answer is 4.

:)

 

Input

A sequence of min and max operations.
Operands are integers in the range between 0 and 9.

'M' denotes max and 'm' denotes min.

There is a symbol '=' at the end of input. 

No blanks between elements.

The length of input (including '=') is less than or equal to 40.

Output

Print the answer.

No newline character at the end of output. 

Sample Input  Download

Sample Output  Download

Tags

so hard



Discuss