# coding: utf-8
from operator import add, sub, mul

op_dict = {'+': add, '-': sub, '*': mul}

def calcurate(list_):
    s = []
    for l in list_:
        if l.isdigit():
            s.append(int(l))
        elif l in ['+', '-', '*']:
            a = s.pop()
            b = s.pop()
            s.append(op_dict[l](b, a))
    return s[0]



def main():
    inputs = raw_input().split()
    print calcurate(inputs)


if __name__ == '__main__':
    main() from operator import add, sub, mul op_dict = {'+': add, '-': sub, '*': mul} op_dict {'+': add, '-': sub, '*': mul} '+' '+' add '-' '-' sub '*' '*' mul def calcurate(list_):
    s = []
    for l in list_:
        if l.isdigit():
            s.append(int(l))
        elif l in ['+', '-', '*']:
            a = s.pop()
            b = s.pop()
            s.append(op_dict[l](b, a))
    return s[0] calcurate s = [] s [] for l in list_:
        if l.isdigit():
            s.append(int(l))
        elif l in ['+', '-', '*']:
            a = s.pop()
            b = s.pop()
            s.append(op_dict[l](b, a))
     l list_ if l.isdigit():
            s.append(int(l))
        elif l in ['+', '-', '*']:
            a = s.pop()
            b = s.pop()
            s.append(op_dict[l](b, a))
     l.isdigit() l.isdigit l isdigit s.append(int(l)) s.append s append int(l) int l elif l in ['+', '-', '*']:
            a = s.pop()
            b = s.pop()
            s.append(op_dict[l](b, a))
     l in ['+', '-', '*'] l ['+', '-', '*'] '+' '-' '*' a = s.pop() a s.pop() s.pop s pop b = s.pop() b s.pop() s.pop s pop s.append(op_dict[l](b, a)) s.append s append op_dict[l](b, a) [l] op_dict l b a return s[0] s[0] s 0 list_ list_ def main():
    inputs = raw_input().split()
    print calcurate(inputs) main inputs = raw_input().split() inputs raw_input().split() ().split () raw_input split print calcurate(inputs) calcurate inputs if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def calcurate(list_):
    s = []
    for l in list_:
        if l.isdigit():
            s.append(int(l))
        elif l in ['+', '-', '*']:
            a = s.pop()
            b = s.pop()
            s.append(op_dict[l](b, a))
    return s[0] def calcurate(list_):
    s = []
    for l in list_:
        if l.isdigit():
            s.append(int(l))
        elif l in ['+', '-', '*']:
            a = s.pop()
            b = s.pop()
            s.append(op_dict[l](b, a))
    return s[0] calcurate def main():
    inputs = raw_input().split()
    print calcurate(inputs) def main():
    inputs = raw_input().split()
    print calcurate(inputs) main op_dict = {'+': add, '-': sub, '*': mul} {'+': add, '-': sub, '*': mul} op_dict
# coding: utf-8
from operator import add, sub, mul

op_dict = {'+': add, '-': sub, '*': mul}

def calcurate(list_):
    s = []
    for l in list_:
        if l.isdigit():
            s.append(int(l))
        elif l in ['+', '-', '*']:
            a = s.pop()
            b = s.pop()
            s.append(op_dict[l](b, a))
    return s[0]



def main():
    inputs = raw_input().split()
    print calcurate(inputs)


if __name__ == '__main__':
    main()