#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def calc(operator, stack):
    val_b = stack.pop()
    val_a = stack.pop()

    if operator == '+':
        stack.append(val_a + val_b)
    elif operator == '-':
        stack.append(val_a - val_b)
    elif operator == '*':
        stack.append(val_a * val_b)
    else:
        raise ValueError

stack = list()
inline = sys.stdin.readline().split()  # List of string
for val in inline:
    if val in '+-*':
        calc(val, stack)
    else:
        stack.append(int(val))

print(stack.pop())

 import sys sys def calc(operator, stack):
    val_b = stack.pop()
    val_a = stack.pop()

    if operator == '+':
        stack.append(val_a + val_b)
    elif operator == '-':
        stack.append(val_a - val_b)
    elif operator == '*':
        stack.append(val_a * val_b)
    else:
        raise ValueError calc val_b = stack.pop() val_b stack.pop() stack.pop stack pop val_a = stack.pop() val_a stack.pop() stack.pop stack pop if operator == '+':
        stack.append(val_a + val_b)
    elif operator == '-':
        stack.append(val_a - val_b)
    elif operator == '*':
        stack.append(val_a * val_b)
    else:
        raise ValueError operator == '+' operator '+' stack.append(val_a + val_b) stack.append stack append val_a + val_b val_a val_b elif operator == '-':
        stack.append(val_a - val_b)
     operator == '-' operator '-' stack.append(val_a - val_b) stack.append stack append val_a - val_b val_a val_b elif operator == '*':
        stack.append(val_a * val_b)
     operator == '*' operator '*' stack.append(val_a * val_b) stack.append stack append val_a * val_b val_a val_b raise ValueError ValueError operator operator stack stack stack = list() stack list() list inline = sys.stdin.readline().split() inline sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for val in inline:
    if val in '+-*':
        calc(val, stack)
    else:
        stack.append(int(val)) val inline if val in '+-*':
        calc(val, stack)
    else:
        stack.append(int(val)) val in '+-*' val '+-*' calc(val, stack) calc val stack stack.append(int(val)) stack.append stack append int(val) int val print(stack.pop()) print stack.pop() stack.pop stack pop inline = sys.stdin.readline().split() sys.stdin.readline().split() inline stack = list() list() stack def calc(operator, stack):
    val_b = stack.pop()
    val_a = stack.pop()

    if operator == '+':
        stack.append(val_a + val_b)
    elif operator == '-':
        stack.append(val_a - val_b)
    elif operator == '*':
        stack.append(val_a * val_b)
    else:
        raise ValueError def calc(operator, stack):
    val_b = stack.pop()
    val_a = stack.pop()

    if operator == '+':
        stack.append(val_a + val_b)
    elif operator == '-':
        stack.append(val_a - val_b)
    elif operator == '*':
        stack.append(val_a * val_b)
    else:
        raise ValueError calc
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def calc(operator, stack):
    val_b = stack.pop()
    val_a = stack.pop()

    if operator == '+':
        stack.append(val_a + val_b)
    elif operator == '-':
        stack.append(val_a - val_b)
    elif operator == '*':
        stack.append(val_a * val_b)
    else:
        raise ValueError

stack = list()
inline = sys.stdin.readline().split()  # List of string
for val in inline:
    if val in '+-*':
        calc(val, stack)
    else:
        stack.append(int(val))

print(stack.pop())


