def push(x, top, S):

      S.append(x)

      top = top + 1



def pop(top):

      del S[top-1]

      top = top - 1



if __name__ == "__main__":

      stdin = eval(input())

      stdin = stdin.split()

      n = len(stdin)

      S = []

      top = len(S)

      for i in range(0, n):

            if stdin[i] == '+':

                  b = S[top-1]

                  a = S[top-2]

                  pop(top)

                  S[top-1] = a + b

            elif stdin[i] == '-':

                  b = S[top-1]

                  a = S[top-2]

                  pop(top)

                  S[top-1] = a - b

            elif stdin[i] == '*':

                  b = S[top-1]

                  a = S[top-2]

                  pop(top)

                  S[top-1] = a * b

            else:

                  push(int(stdin[i]), top, S)

      print((S[top]))
def push(S, top, x):

      S.append(x)

      top = top + 1



def pop(S, top):

      t = int(S[top-1])

      del S[top-1]

      top = top -1

      return t



if __name__ == "__main__":

      top = 0

      inpt = (eval(input())).split()

      n = len(inpt)

      S = []

      for i in range(0,n):

            if inpt[i] == "+":

                  b = pop(S, top)

                  a = pop(S, top)

                  c = a + b

                  push(S, top, c)

            elif inpt[i] == "-":

                  b = pop(S, top)

                  a = pop(S, top)

                  c = a - b

                  push(S, top, c)

            elif inpt[i] == "*":

                  b = pop(S, top)

                  a = pop(S, top)

                  c = a * b

                  push(S, top, c)

            else :

                  push(S, top, int(inpt[i]))

      print((S[top-1]))
def push(x, top, S):
    S.append(x)
    top = top + 1


def pop(top):
    del S[top - 1]
    top = top - 1


if __name__ == "__main__":
    stdin = eval(input())
    stdin = stdin.split()
    n = len(stdin)
    S = []
    top = len(S)
    for i in range(0, n):
        if stdin[i] == "+":
            b = S[top - 1]
            a = S[top - 2]
            pop(top)
            S[top - 1] = a + b
        elif stdin[i] == "-":
            b = S[top - 1]
            a = S[top - 2]
            pop(top)
            S[top - 1] = a - b
        elif stdin[i] == "*":
            b = S[top - 1]
            a = S[top - 2]
            pop(top)
            S[top - 1] = a * b
        else:
            push(int(stdin[i]), top, S)
    print((S[top]))

def push(S, top, x):
    S.append(x)
    top = top + 1


def pop(S, top):
    t = int(S[top - 1])
    del S[top - 1]
    top = top - 1
    return t


if __name__ == "__main__":
    top = 0
    inpt = (eval(input())).split()
    n = len(inpt)
    S = []
    for i in range(0, n):
        if inpt[i] == "+":
            b = pop(S, top)
            a = pop(S, top)
            c = a + b
            push(S, top, c)
        elif inpt[i] == "-":
            b = pop(S, top)
            a = pop(S, top)
            c = a - b
            push(S, top, c)
        elif inpt[i] == "*":
            b = pop(S, top)
            a = pop(S, top)
            c = a * b
            push(S, top, c)
        else:
            push(S, top, int(inpt[i]))
    print((S[top - 1]))

-def push(x, top, S): +def push(S, top, x): -def pop(top): +def pop(S, top): +    t = int(S[top - 1]) +    return t -    stdin = eval(input()) -    stdin = stdin.split() -    n = len(stdin) +    top = 0 +    inpt = (eval(input())).split() +    n = len(inpt) -    top = len(S) -        if stdin[i] == "+": -            b = S[top - 1] -            a = S[top - 2] -            pop(top) -            S[top - 1] = a + b -        elif stdin[i] == "-": -            b = S[top - 1] -            a = S[top - 2] -            pop(top) -            S[top - 1] = a - b -        elif stdin[i] == "*": -            b = S[top - 1] -            a = S[top - 2] -            pop(top) -            S[top - 1] = a * b +        if inpt[i] == "+": +            b = pop(S, top) +            a = pop(S, top) +            c = a + b +            push(S, top, c) +        elif inpt[i] == "-": +            b = pop(S, top) +            a = pop(S, top) +            c = a - b +            push(S, top, c) +        elif inpt[i] == "*": +            b = pop(S, top) +            a = pop(S, top) +            c = a * b +            push(S, top, c) -            push(int(stdin[i]), top, S) -    print((S[top])) +            push(S, top, int(inpt[i])) +    print((S[top - 1]))