top = 0
def push(x):
    global top
    L.append(x)
    top += 1
def pop():
    global top
    x = L.pop(top)
    top -= 1
    return x

L = [0]
S = input().split()
for i in S:
    if i == "+":
        a = pop()
        b = pop()
        push(a + b)
    elif i == "-":
        a = pop()
        b = pop()
        push(b - a)
    elif i == "*":
        a = pop()
        b = pop()
        push(a * b)
    else:
        push(int(i))

print(str(pop())) top = 0 top 0 def push(x):
    global top
    L.append(x)
    top += 1 push global top L.append(x) L.append L append x top += 1 top 1 x x def pop():
    global top
    x = L.pop(top)
    top -= 1
    return x pop global top x = L.pop(top) x L.pop(top) L.pop L pop top top -= 1 top 1 return x x L = [0] L [0] 0 S = input().split() S input().split() ().split () input split for i in S:
    if i == "+":
        a = pop()
        b = pop()
        push(a + b)
    elif i == "-":
        a = pop()
        b = pop()
        push(b - a)
    elif i == "*":
        a = pop()
        b = pop()
        push(a * b)
    else:
        push(int(i)) i S if i == "+":
        a = pop()
        b = pop()
        push(a + b)
    elif i == "-":
        a = pop()
        b = pop()
        push(b - a)
    elif i == "*":
        a = pop()
        b = pop()
        push(a * b)
    else:
        push(int(i)) i == "+" i "+" a = pop() a pop() pop b = pop() b pop() pop push(a + b) push a + b a b elif i == "-":
        a = pop()
        b = pop()
        push(b - a)
     i == "-" i "-" a = pop() a pop() pop b = pop() b pop() pop push(b - a) push b - a b a elif i == "*":
        a = pop()
        b = pop()
        push(a * b)
     i == "*" i "*" a = pop() a pop() pop b = pop() b pop() pop push(a * b) push a * b a b push(int(i)) push int(i) int i print(str(pop())) print str(pop()) str pop() pop def push(x):
    global top
    L.append(x)
    top += 1 def push(x):
    global top
    L.append(x)
    top += 1 push a = pop() pop() a a = pop() pop() a b = pop() pop() b S = input().split() input().split() S top = 0 0 top b = pop() pop() b def pop():
    global top
    x = L.pop(top)
    top -= 1
    return x def pop():
    global top
    x = L.pop(top)
    top -= 1
    return x pop L = [0] [0] L a = pop() pop() a b = pop() pop() b
top = 0
def push(x):
    global top
    L.append(x)
    top += 1
def pop():
    global top
    x = L.pop(top)
    top -= 1
    return x

L = [0]
S = input().split()
for i in S:
    if i == "+":
        a = pop()
        b = pop()
        push(a + b)
    elif i == "-":
        a = pop()
        b = pop()
        push(b - a)
    elif i == "*":
        a = pop()
        b = pop()
        push(a * b)
    else:
        push(int(i))

print(str(pop()))