# -*- coding: utf-8 -*-

list = map(str, raw_input().split())
num = []
for i in list:
    if i == '+':
        num[len(num)-2] += num.pop()
    elif i == '-':
        num[len(num)-2] -= num.pop()
    elif i == '*':
        num[len(num)-2] *= num.pop()
    else:
        num.append(int(i))
print num[0] list = map(str, raw_input().split()) list map(str, raw_input().split()) map str raw_input().split() ().split () raw_input split num = [] num [] for i in list:
    if i == '+':
        num[len(num)-2] += num.pop()
    elif i == '-':
        num[len(num)-2] -= num.pop()
    elif i == '*':
        num[len(num)-2] *= num.pop()
    else:
        num.append(int(i)) i list if i == '+':
        num[len(num)-2] += num.pop()
    elif i == '-':
        num[len(num)-2] -= num.pop()
    elif i == '*':
        num[len(num)-2] *= num.pop()
    else:
        num.append(int(i)) i == '+' i '+' num[len(num)-2] += num.pop() num[len(num)-2] num len(num)-2 len(num) len num 2 num.pop() num.pop num pop elif i == '-':
        num[len(num)-2] -= num.pop()
     i == '-' i '-' num[len(num)-2] -= num.pop() num[len(num)-2] num len(num)-2 len(num) len num 2 num.pop() num.pop num pop elif i == '*':
        num[len(num)-2] *= num.pop()
     i == '*' i '*' num[len(num)-2] *= num.pop() num[len(num)-2] num len(num)-2 len(num) len num 2 num.pop() num.pop num pop num.append(int(i)) num.append num append int(i) int i print num[0] num 0 num = [] [] num list = map(str, raw_input().split()) map(str, raw_input().split()) list
# -*- coding: utf-8 -*-

list = map(str, raw_input().split())
num = []
for i in list:
    if i == '+':
        num[len(num)-2] += num.pop()
    elif i == '-':
        num[len(num)-2] -= num.pop()
    elif i == '*':
        num[len(num)-2] *= num.pop()
    else:
        num.append(int(i))
print num[0]