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 = input()
      stdin = stdin.split()
      n = len(stdin)
      S = []
      top = len(S)
      for i in range(0, n):
            if stdin[i] == '+':
                  #print("+++++ top value is {}".format(top))
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a + b
            elif stdin[i] == '-':
                  #print("----- top value is {}".format(top))
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a - b
            elif stdin[i] == '*':
                  #print(print("***** top value is {}".format(top)))
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a * b
            else:
                  push(int(stdin[i]), top, S)
                  #print("when push {} top value is {}".format(int(stdin[i]),top))
      print(S[top]) def push(x, top, S):
      S.append(x)
      top = top + 1 push S.append(x) S.append S append x top = top + 1 top top + 1 top 1 x x top top S S def pop(top):
      del S[top-1]
      top = top - 1 pop del S[top-1] S[top-1] S top-1 top 1 top = top - 1 top top - 1 top 1 top top if __name__ == "__main__":
      stdin = input()
      stdin = stdin.split()
      n = len(stdin)
      S = []
      top = len(S)
      for i in range(0, n):
            if stdin[i] == '+':
                  #print("+++++ top value is {}".format(top))
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a + b
            elif stdin[i] == '-':
                  #print("----- top value is {}".format(top))
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a - b
            elif stdin[i] == '*':
                  #print(print("***** top value is {}".format(top)))
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a * b
            else:
                  push(int(stdin[i]), top, S)
                  #print("when push {} top value is {}".format(int(stdin[i]),top))
      print(S[top]) __name__ == "__main__" __name__ "__main__" stdin = input() stdin input() input stdin = stdin.split() stdin stdin.split() stdin.split stdin split n = len(stdin) n len(stdin) len stdin S = [] S [] top = len(S) top len(S) len S for i in range(0, n):
            if stdin[i] == '+':
                  #print("+++++ top value is {}".format(top))
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a + b
            elif stdin[i] == '-':
                  #print("----- top value is {}".format(top))
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a - b
            elif stdin[i] == '*':
                  #print(print("***** top value is {}".format(top)))
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a * b
            else:
                  push(int(stdin[i]), top, S)
                  #print("when push {} top value is {}".format(int(stdin[i]),top))
       i range(0, n) range 0 n if stdin[i] == '+':
                  #print("+++++ top value is {}".format(top))
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a + b
            elif stdin[i] == '-':
                  #print("----- top value is {}".format(top))
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a - b
            elif stdin[i] == '*':
                  #print(print("***** top value is {}".format(top)))
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a * b
            else:
                  push(int(stdin[i]), top, S)
                  #print("when push {} top value is {}".format(int(stdin[i]),top))
       stdin[i] == '+' stdin[i] stdin i '+' b = S[top-1] b S[top-1] S top-1 top 1 a = S[top-2] a S[top-2] S top-2 top 2 pop(top) pop top S[top-1] = a + b S[top-1] S top-1 top 1 a + b a b elif stdin[i] == '-':
                  #print("----- top value is {}".format(top))
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a - b
             stdin[i] == '-' stdin[i] stdin i '-' b = S[top-1] b S[top-1] S top-1 top 1 a = S[top-2] a S[top-2] S top-2 top 2 pop(top) pop top S[top-1] = a - b S[top-1] S top-1 top 1 a - b a b elif stdin[i] == '*':
                  #print(print("***** top value is {}".format(top)))
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a * b
             stdin[i] == '*' stdin[i] stdin i '*' b = S[top-1] b S[top-1] S top-1 top 1 a = S[top-2] a S[top-2] S top-2 top 2 pop(top) pop top S[top-1] = a * b S[top-1] S top-1 top 1 a * b a b push(int(stdin[i]), top, S) push int(stdin[i]) int stdin[i] stdin i top S print(S[top]) print S[top] S top def push(x, top, S):
      S.append(x)
      top = top + 1 def push(x, top, S):
      S.append(x)
      top = top + 1 push b = S[top-1] S[top-1] b b = S[top-1] S[top-1] b a = S[top-2] S[top-2] a a = S[top-2] S[top-2] a top = len(S) len(S) top stdin = stdin.split() stdin.split() stdin n = len(stdin) len(stdin) n a = S[top-2] S[top-2] a stdin = input() input() stdin def pop(top):
      del S[top-1]
      top = top - 1 def pop(top):
      del S[top-1]
      top = top - 1 pop S = [] [] S b = S[top-1] S[top-1] b
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 = input()
      stdin = stdin.split()
      n = len(stdin)
      S = []
      top = len(S)
      for i in range(0, n):
            if stdin[i] == '+':
                  #print("+++++ top value is {}".format(top))
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a + b
            elif stdin[i] == '-':
                  #print("----- top value is {}".format(top))
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a - b
            elif stdin[i] == '*':
                  #print(print("***** top value is {}".format(top)))
                  b = S[top-1]
                  a = S[top-2]
                  pop(top)
                  S[top-1] = a * b
            else:
                  push(int(stdin[i]), top, S)
                  #print("when push {} top value is {}".format(int(stdin[i]),top))
      print(S[top])