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

import sys
import os


lst = input().split()
stack = []

for c in lst:
    if c == '+':
        a = stack.pop()
        b = stack.pop()
        stack.append(b + a)
    elif c == '-':
        a = stack.pop()
        b = stack.pop()
        stack.append(b - a)
    elif c == '*':
        a = stack.pop()
        b = stack.pop()
        stack.append(b * a)
    else:
        stack.append(int(c))
print(stack[0]) import sys sys import os os lst = input().split() lst input().split() ().split () input split stack = [] stack [] for c in lst:
    if c == '+':
        a = stack.pop()
        b = stack.pop()
        stack.append(b + a)
    elif c == '-':
        a = stack.pop()
        b = stack.pop()
        stack.append(b - a)
    elif c == '*':
        a = stack.pop()
        b = stack.pop()
        stack.append(b * a)
    else:
        stack.append(int(c)) c lst if c == '+':
        a = stack.pop()
        b = stack.pop()
        stack.append(b + a)
    elif c == '-':
        a = stack.pop()
        b = stack.pop()
        stack.append(b - a)
    elif c == '*':
        a = stack.pop()
        b = stack.pop()
        stack.append(b * a)
    else:
        stack.append(int(c)) c == '+' c '+' a = stack.pop() a stack.pop() stack.pop stack pop b = stack.pop() b stack.pop() stack.pop stack pop stack.append(b + a) stack.append stack append b + a b a elif c == '-':
        a = stack.pop()
        b = stack.pop()
        stack.append(b - a)
     c == '-' c '-' a = stack.pop() a stack.pop() stack.pop stack pop b = stack.pop() b stack.pop() stack.pop stack pop stack.append(b - a) stack.append stack append b - a b a elif c == '*':
        a = stack.pop()
        b = stack.pop()
        stack.append(b * a)
     c == '*' c '*' a = stack.pop() a stack.pop() stack.pop stack pop b = stack.pop() b stack.pop() stack.pop stack pop stack.append(b * a) stack.append stack append b * a b a stack.append(int(c)) stack.append stack append int(c) int c print(stack[0]) print stack[0] stack 0 b = stack.pop() stack.pop() b stack = [] [] stack a = stack.pop() stack.pop() a b = stack.pop() stack.pop() b a = stack.pop() stack.pop() a a = stack.pop() stack.pop() a b = stack.pop() stack.pop() b lst = input().split() input().split() lst
# -*- coding: utf-8 -*-

import sys
import os


lst = input().split()
stack = []

for c in lst:
    if c == '+':
        a = stack.pop()
        b = stack.pop()
        stack.append(b + a)
    elif c == '-':
        a = stack.pop()
        b = stack.pop()
        stack.append(b - a)
    elif c == '*':
        a = stack.pop()
        b = stack.pop()
        stack.append(b * a)
    else:
        stack.append(int(c))
print(stack[0])