data = input().split()

# ??????????????????????????????????£?
# n : ????????????????????????
# S : ????????????
n = 1000
S = [0 for i in range(n)]

def isEmpty():
    global top
    if (top == 0):
        return True
    else:
        return False

def isFull():
    global top, n
    return top > n-1

def push(S, x):
    global top
    if isFull():
        print('error: overflow')
        return False
    top += 1
    S[top] = x

def pop(S):
    global top
    if isEmpty():
        print('error: underflow')
        return False
    top -= 1
    return S[top+1]

top = 0

for e in data:


    if e.isdigit():
        push(S, e)
    else:
        a = int(pop(S))
        b = int(pop(S))

        if e == '+':
            push(S, b + a)
        elif e == '-':
            push(S, b - a)
        elif e == '*':
            push(S, b * a)
        else:
            print('error: operand')


print(S[top]) data = input().split() data input().split() ().split () input split n = 1000 n 1000 0 for i in range(n) for i in range(n) i range(n) range n for i in range(n) 0 S = [0 for i in range(n)] S [0 for i in range(n)] def isEmpty():
    global top
    if (top == 0):
        return True
    else:
        return False isEmpty global top if (top == 0):
        return True
    else:
        return False top == 0 top 0 return True True return False False def isFull():
    global top, n
    return top > n-1 isFull global top, n return top > n-1 top > n-1 top n-1 n 1 def push(S, x):
    global top
    if isFull():
        print('error: overflow')
        return False
    top += 1
    S[top] = x push global top if isFull():
        print('error: overflow')
        return False
     isFull() isFull print('error: overflow') print 'error: overflow' return False False top += 1 top 1 S[top] = x S[top] S top x S S x x def pop(S):
    global top
    if isEmpty():
        print('error: underflow')
        return False
    top -= 1
    return S[top+1] pop global top if isEmpty():
        print('error: underflow')
        return False
     isEmpty() isEmpty print('error: underflow') print 'error: underflow' return False False top -= 1 top 1 return S[top+1] S[top+1] S top+1 top 1 S S top = 0 top 0 for e in data:


    if e.isdigit():
        push(S, e)
    else:
        a = int(pop(S))
        b = int(pop(S))

        if e == '+':
            push(S, b + a)
        elif e == '-':
            push(S, b - a)
        elif e == '*':
            push(S, b * a)
        else:
            print('error: operand') e data if e.isdigit():
        push(S, e)
    else:
        a = int(pop(S))
        b = int(pop(S))

        if e == '+':
            push(S, b + a)
        elif e == '-':
            push(S, b - a)
        elif e == '*':
            push(S, b * a)
        else:
            print('error: operand') e.isdigit() e.isdigit e isdigit push(S, e) push S e a = int(pop(S)) a int(pop(S)) int pop(S) pop S b = int(pop(S)) b int(pop(S)) int pop(S) pop S if e == '+':
            push(S, b + a)
        elif e == '-':
            push(S, b - a)
        elif e == '*':
            push(S, b * a)
        else:
            print('error: operand') e == '+' e '+' push(S, b + a) push S b + a b a elif e == '-':
            push(S, b - a)
         e == '-' e '-' push(S, b - a) push S b - a b a elif e == '*':
            push(S, b * a)
         e == '*' e '*' push(S, b * a) push S b * a b a print('error: operand') print 'error: operand' print(S[top]) print S[top] S top S = [0 for i in range(n)] [0 for i in range(n)] S def pop(S):
    global top
    if isEmpty():
        print('error: underflow')
        return False
    top -= 1
    return S[top+1] def pop(S):
    global top
    if isEmpty():
        print('error: underflow')
        return False
    top -= 1
    return S[top+1] pop n = 1000 1000 n def isEmpty():
    global top
    if (top == 0):
        return True
    else:
        return False def isEmpty():
    global top
    if (top == 0):
        return True
    else:
        return False isEmpty data = input().split() input().split() data a = int(pop(S)) int(pop(S)) a def push(S, x):
    global top
    if isFull():
        print('error: overflow')
        return False
    top += 1
    S[top] = x def push(S, x):
    global top
    if isFull():
        print('error: overflow')
        return False
    top += 1
    S[top] = x push b = int(pop(S)) int(pop(S)) b def isFull():
    global top, n
    return top > n-1 def isFull():
    global top, n
    return top > n-1 isFull top = 0 0 top
data = input().split()

# ??????????????????????????????????£?
# n : ????????????????????????
# S : ????????????
n = 1000
S = [0 for i in range(n)]

def isEmpty():
    global top
    if (top == 0):
        return True
    else:
        return False

def isFull():
    global top, n
    return top > n-1

def push(S, x):
    global top
    if isFull():
        print('error: overflow')
        return False
    top += 1
    S[top] = x

def pop(S):
    global top
    if isEmpty():
        print('error: underflow')
        return False
    top -= 1
    return S[top+1]

top = 0

for e in data:


    if e.isdigit():
        push(S, e)
    else:
        a = int(pop(S))
        b = int(pop(S))

        if e == '+':
            push(S, b + a)
        elif e == '-':
            push(S, b - a)
        elif e == '*':
            push(S, b * a)
        else:
            print('error: operand')


print(S[top])