from sys import stdin

def rpn_l(l):
    try:
        if len(l)==1: return l[0]
        for i in xrange(len(l)):
            if i>1 and l[i] in ['+','-','/','*']:
                return rpn_l(l[:i-2]+[str(eval(l[i-2]+l[i]+l[i-1]))]+l[i+1:])
    except: return "Bad input"

def rpn(s):
    return rpn_l(s.split())

print rpn(stdin.read())

