
o = list()
top = -1
for s in input().split():
    if s.isdigit():
        o.append(int(s))
        top += 1
    else:
        if s is "+":
            n = o[top]+o[top-1]
            o.pop(top)
            top-=1
            o.pop(top)
            top-=1
            o.append(n)
            top+=1
        if s is "-":
            n = o[top-1] - o[top]
            o.pop(top)
            top -= 1
            o.pop(top)
            top -= 1
            o.append(n)
            top+=1
        if s is "*":
            n = o[top]*o[top-1]
            o.pop(top)
            top -= 1
            o.pop(top)
            top -= 1
            o.append(n)
            top+=1


print(o[0]) o = list() o list() list top = -1 top -1 for s in input().split():
    if s.isdigit():
        o.append(int(s))
        top += 1
    else:
        if s is "+":
            n = o[top]+o[top-1]
            o.pop(top)
            top-=1
            o.pop(top)
            top-=1
            o.append(n)
            top+=1
        if s is "-":
            n = o[top-1] - o[top]
            o.pop(top)
            top -= 1
            o.pop(top)
            top -= 1
            o.append(n)
            top+=1
        if s is "*":
            n = o[top]*o[top-1]
            o.pop(top)
            top -= 1
            o.pop(top)
            top -= 1
            o.append(n)
            top+=1 s input().split() ().split () input split if s.isdigit():
        o.append(int(s))
        top += 1
    else:
        if s is "+":
            n = o[top]+o[top-1]
            o.pop(top)
            top-=1
            o.pop(top)
            top-=1
            o.append(n)
            top+=1
        if s is "-":
            n = o[top-1] - o[top]
            o.pop(top)
            top -= 1
            o.pop(top)
            top -= 1
            o.append(n)
            top+=1
        if s is "*":
            n = o[top]*o[top-1]
            o.pop(top)
            top -= 1
            o.pop(top)
            top -= 1
            o.append(n)
            top+=1 s.isdigit() s.isdigit s isdigit o.append(int(s)) o.append o append int(s) int s top += 1 top 1 if s is "+":
            n = o[top]+o[top-1]
            o.pop(top)
            top-=1
            o.pop(top)
            top-=1
            o.append(n)
            top+=1
         s is "+" s "+" n = o[top]+o[top-1] n o[top]+o[top-1] o[top] o top o[top-1] o top-1 top 1 o.pop(top) o.pop o pop top top-=1 top 1 o.pop(top) o.pop o pop top top-=1 top 1 o.append(n) o.append o append n top+=1 top 1 if s is "-":
            n = o[top-1] - o[top]
            o.pop(top)
            top -= 1
            o.pop(top)
            top -= 1
            o.append(n)
            top+=1
         s is "-" s "-" n = o[top-1] - o[top] n o[top-1] - o[top] o[top-1] o top-1 top 1 o[top] o top o.pop(top) o.pop o pop top top -= 1 top 1 o.pop(top) o.pop o pop top top -= 1 top 1 o.append(n) o.append o append n top+=1 top 1 if s is "*":
            n = o[top]*o[top-1]
            o.pop(top)
            top -= 1
            o.pop(top)
            top -= 1
            o.append(n)
            top+=1 s is "*" s "*" n = o[top]*o[top-1] n o[top]*o[top-1] o[top] o top o[top-1] o top-1 top 1 o.pop(top) o.pop o pop top top -= 1 top 1 o.pop(top) o.pop o pop top top -= 1 top 1 o.append(n) o.append o append n top+=1 top 1 print(o[0]) print o[0] o 0 top -= 1 1 top top -= 1 1 top top -= 1 1 top top+=1 1 top o = list() list() o n = o[top-1] - o[top] o[top-1] - o[top] n n = o[top]+o[top-1] o[top]+o[top-1] n n = o[top]*o[top-1] o[top]*o[top-1] n top+=1 1 top top+=1 1 top top-=1 1 top top = -1 -1 top top-=1 1 top top -= 1 1 top top += 1 1 top

o = list()
top = -1
for s in input().split():
    if s.isdigit():
        o.append(int(s))
        top += 1
    else:
        if s is "+":
            n = o[top]+o[top-1]
            o.pop(top)
            top-=1
            o.pop(top)
            top-=1
            o.append(n)
            top+=1
        if s is "-":
            n = o[top-1] - o[top]
            o.pop(top)
            top -= 1
            o.pop(top)
            top -= 1
            o.append(n)
            top+=1
        if s is "*":
            n = o[top]*o[top-1]
            o.pop(top)
            top -= 1
            o.pop(top)
            top -= 1
            o.append(n)
            top+=1


print(o[0])