# -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 14:04:29 2018
ALDS1-3a
@author: maezawa
"""
maxn=200
s = input().split()
st = [0 for _ in range(maxn)]
top = 0

for i in range(len(s)):
    c = s.pop(0)
    if c == '+':
        b = st[top]
        top -= 1
        a = st[top]
        top -= 1
        ans = a + b
        top += 1
        st[top] = ans
    elif c == '-':
        b = st[top]
        top -= 1
        a = st[top]
        top -= 1
        ans = a - b
        top += 1
        st[top] = ans
    elif c == '*':
        b = st[top]
        top -= 1
        a = st[top]
        top -= 1
        ans = a * b
        top += 1
        st[top] = ans
    else:
        top += 1
        st[top] = int(c)
print(st[top]) """
Created on Sun Apr 29 14:04:29 2018
ALDS1-3a
@author: maezawa
""" maxn=200 maxn 200 s = input().split() s input().split() ().split () input split 0 for _ in range(maxn) for _ in range(maxn) _ range(maxn) range maxn for _ in range(maxn) 0 st = [0 for _ in range(maxn)] st [0 for _ in range(maxn)] top = 0 top 0 for i in range(len(s)):
    c = s.pop(0)
    if c == '+':
        b = st[top]
        top -= 1
        a = st[top]
        top -= 1
        ans = a + b
        top += 1
        st[top] = ans
    elif c == '-':
        b = st[top]
        top -= 1
        a = st[top]
        top -= 1
        ans = a - b
        top += 1
        st[top] = ans
    elif c == '*':
        b = st[top]
        top -= 1
        a = st[top]
        top -= 1
        ans = a * b
        top += 1
        st[top] = ans
    else:
        top += 1
        st[top] = int(c) i range(len(s)) range len(s) len s c = s.pop(0) c s.pop(0) s.pop s pop 0 if c == '+':
        b = st[top]
        top -= 1
        a = st[top]
        top -= 1
        ans = a + b
        top += 1
        st[top] = ans
    elif c == '-':
        b = st[top]
        top -= 1
        a = st[top]
        top -= 1
        ans = a - b
        top += 1
        st[top] = ans
    elif c == '*':
        b = st[top]
        top -= 1
        a = st[top]
        top -= 1
        ans = a * b
        top += 1
        st[top] = ans
    else:
        top += 1
        st[top] = int(c) c == '+' c '+' b = st[top] b st[top] st top top -= 1 top 1 a = st[top] a st[top] st top top -= 1 top 1 ans = a + b ans a + b a b top += 1 top 1 st[top] = ans st[top] st top ans elif c == '-':
        b = st[top]
        top -= 1
        a = st[top]
        top -= 1
        ans = a - b
        top += 1
        st[top] = ans
     c == '-' c '-' b = st[top] b st[top] st top top -= 1 top 1 a = st[top] a st[top] st top top -= 1 top 1 ans = a - b ans a - b a b top += 1 top 1 st[top] = ans st[top] st top ans elif c == '*':
        b = st[top]
        top -= 1
        a = st[top]
        top -= 1
        ans = a * b
        top += 1
        st[top] = ans
     c == '*' c '*' b = st[top] b st[top] st top top -= 1 top 1 a = st[top] a st[top] st top top -= 1 top 1 ans = a * b ans a * b a b top += 1 top 1 st[top] = ans st[top] st top ans top += 1 top 1 st[top] = int(c) st[top] st top int(c) int c print(st[top]) print st[top] st top top -= 1 1 top top -= 1 1 top top += 1 1 top ans = a * b a * b ans b = st[top] st[top] b top -= 1 1 top c = s.pop(0) s.pop(0) c s = input().split() input().split() s top += 1 1 top a = st[top] st[top] a b = st[top] st[top] b b = st[top] st[top] b maxn=200 200 maxn ans = a - b a - b ans top = 0 0 top ans = a + b a + b ans top -= 1 1 top top += 1 1 top st = [0 for _ in range(maxn)] [0 for _ in range(maxn)] st top -= 1 1 top top -= 1 1 top top += 1 1 top a = st[top] st[top] a a = st[top] st[top] a
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 14:04:29 2018
ALDS1-3a
@author: maezawa
"""
maxn=200
s = input().split()
st = [0 for _ in range(maxn)]
top = 0

for i in range(len(s)):
    c = s.pop(0)
    if c == '+':
        b = st[top]
        top -= 1
        a = st[top]
        top -= 1
        ans = a + b
        top += 1
        st[top] = ans
    elif c == '-':
        b = st[top]
        top -= 1
        a = st[top]
        top -= 1
        ans = a - b
        top += 1
        st[top] = ans
    elif c == '*':
        b = st[top]
        top -= 1
        a = st[top]
        top -= 1
        ans = a * b
        top += 1
        st[top] = ans
    else:
        top += 1
        st[top] = int(c)
print(st[top])
