# -*- coding: UTF-8 -*-
# Stack

top = 0
S = {}

def push(x):
    global top
    global S
    top += 1
    S[top] = x

def pop():
    global top
    global S
    top -= 1
    return S[top + 1]

input_list = list(input().split()) #計算対象（スペース区切り→配列に展開）

for target in input_list:
    if target == '+':
        a = pop()
        b = pop()
        c = b+a
        push(c)
    elif target == '-':
        a = pop()
        b = pop()
        c = b-a
        push(c)
    elif target == '*':
        a = pop()
        b = pop()
        c = b*a
        push(c)
    else:
        push(int(target))

print(pop())
 top = 0 top 0 S = {} S {} def push(x):
    global top
    global S
    top += 1
    S[top] = x push global top global S top += 1 top 1 S[top] = x S[top] S top x x x def pop():
    global top
    global S
    top -= 1
    return S[top + 1] pop global top global S top -= 1 top 1 return S[top + 1] S[top + 1] S top + 1 top 1 input_list = list(input().split()) input_list list(input().split()) list input().split() ().split () input split for target in input_list:
    if target == '+':
        a = pop()
        b = pop()
        c = b+a
        push(c)
    elif target == '-':
        a = pop()
        b = pop()
        c = b-a
        push(c)
    elif target == '*':
        a = pop()
        b = pop()
        c = b*a
        push(c)
    else:
        push(int(target)) target input_list if target == '+':
        a = pop()
        b = pop()
        c = b+a
        push(c)
    elif target == '-':
        a = pop()
        b = pop()
        c = b-a
        push(c)
    elif target == '*':
        a = pop()
        b = pop()
        c = b*a
        push(c)
    else:
        push(int(target)) target == '+' target '+' a = pop() a pop() pop b = pop() b pop() pop c = b+a c b+a b a push(c) push c elif target == '-':
        a = pop()
        b = pop()
        c = b-a
        push(c)
     target == '-' target '-' a = pop() a pop() pop b = pop() b pop() pop c = b-a c b-a b a push(c) push c elif target == '*':
        a = pop()
        b = pop()
        c = b*a
        push(c)
     target == '*' target '*' a = pop() a pop() pop b = pop() b pop() pop c = b*a c b*a b a push(c) push c push(int(target)) push int(target) int target print(pop()) print pop() pop b = pop() pop() b S = {} {} S b = pop() pop() b c = b-a b-a c a = pop() pop() a c = b*a b*a c def push(x):
    global top
    global S
    top += 1
    S[top] = x def push(x):
    global top
    global S
    top += 1
    S[top] = x push c = b+a b+a c input_list = list(input().split()) list(input().split()) input_list a = pop() pop() a a = pop() pop() a top = 0 0 top b = pop() pop() b def pop():
    global top
    global S
    top -= 1
    return S[top + 1] def pop():
    global top
    global S
    top -= 1
    return S[top + 1] pop
# -*- coding: UTF-8 -*-
# Stack

top = 0
S = {}

def push(x):
    global top
    global S
    top += 1
    S[top] = x

def pop():
    global top
    global S
    top -= 1
    return S[top + 1]

input_list = list(input().split()) #計算対象（スペース区切り→配列に展開）

for target in input_list:
    if target == '+':
        a = pop()
        b = pop()
        c = b+a
        push(c)
    elif target == '-':
        a = pop()
        b = pop()
        c = b-a
        push(c)
    elif target == '*':
        a = pop()
        b = pop()
        c = b*a
        push(c)
    else:
        push(int(target))

print(pop())

