from collections import deque N,*A=(input()+' '+input()).split() d=deque() for s in A: if s=='+':d.append(+d.pop()+d.pop()) elif s=='-':d.append(-d.pop()+d.pop()) else: d.append(int(s)) print(d.pop())