class Stack(list):
    def __init__(self):
        self.length = 0
    def __len__(self):
        return self.length

    def push(self,x):
        self.insert(len(self),x)
        self.length += 1
    def pop(self):
        try:
            if(len(self)==0):
                raise NameError("stack is empty")
            tmp = self[len(self)-1]
            self.length -= 1
            return tmp
        except:
            print("stack is empty!!!!")
            return '#'

data = Stack()
s = input()
x = s.split()

for i in x:
    if i == '+':
        a = data.pop()
        b = data.pop()
        data.push(b+a)

    elif i == '-':
        a = data.pop()
        b = data.pop()
        data.push(b-a)


    elif i == '*':
        a = data.pop()
        b = data.pop()
        data.push(b*a)
  
    else:
        data.push(int(i))
print(data.pop()) class Stack(list):
    def __init__(self):
        self.length = 0
    def __len__(self):
        return self.length

    def push(self,x):
        self.insert(len(self),x)
        self.length += 1
    def pop(self):
        try:
            if(len(self)==0):
                raise NameError("stack is empty")
            tmp = self[len(self)-1]
            self.length -= 1
            return tmp
        except:
            print("stack is empty!!!!")
            return '#' Stack def __init__(self):
        self.length = 0
     __init__ self.length = 0 self.length self length 0 self self def __len__(self):
        return self.length

     __len__ return self.length self.length self length self self def push(self,x):
        self.insert(len(self),x)
        self.length += 1
     push self.insert(len(self),x) self.insert self insert len(self) len self x self.length += 1 self.length self length 1 self self x x def pop(self):
        try:
            if(len(self)==0):
                raise NameError("stack is empty")
            tmp = self[len(self)-1]
            self.length -= 1
            return tmp
        except:
            print("stack is empty!!!!")
            return '#' pop try:
            if(len(self)==0):
                raise NameError("stack is empty")
            tmp = self[len(self)-1]
            self.length -= 1
            return tmp
        except:
            print("stack is empty!!!!")
            return '#' except:
            print("stack is empty!!!!")
            return '#' print("stack is empty!!!!") print "stack is empty!!!!" return '#' '#' if(len(self)==0):
                raise NameError("stack is empty")
             len(self)==0 len(self) len self 0 raise NameError("stack is empty") NameError("stack is empty") NameError "stack is empty" tmp = self[len(self)-1] tmp self[len(self)-1] self len(self)-1 len(self) len self 1 self.length -= 1 self.length self length 1 return tmp tmp self self list data = Stack() data Stack() Stack s = input() s input() input x = s.split() x s.split() s.split s split for i in x:
    if i == '+':
        a = data.pop()
        b = data.pop()
        data.push(b+a)

    elif i == '-':
        a = data.pop()
        b = data.pop()
        data.push(b-a)


    elif i == '*':
        a = data.pop()
        b = data.pop()
        data.push(b*a)
  
    else:
        data.push(int(i)) i x if i == '+':
        a = data.pop()
        b = data.pop()
        data.push(b+a)

    elif i == '-':
        a = data.pop()
        b = data.pop()
        data.push(b-a)


    elif i == '*':
        a = data.pop()
        b = data.pop()
        data.push(b*a)
  
    else:
        data.push(int(i)) i == '+' i '+' a = data.pop() a data.pop() data.pop data pop b = data.pop() b data.pop() data.pop data pop data.push(b+a) data.push data push b+a b a elif i == '-':
        a = data.pop()
        b = data.pop()
        data.push(b-a)


     i == '-' i '-' a = data.pop() a data.pop() data.pop data pop b = data.pop() b data.pop() data.pop data pop data.push(b-a) data.push data push b-a b a elif i == '*':
        a = data.pop()
        b = data.pop()
        data.push(b*a)
  
     i == '*' i '*' a = data.pop() a data.pop() data.pop data pop b = data.pop() b data.pop() data.pop data pop data.push(b*a) data.push data push b*a b a data.push(int(i)) data.push data push int(i) int i print(data.pop()) print data.pop() data.pop data pop x = s.split() s.split() x b = data.pop() data.pop() b a = data.pop() data.pop() a data = Stack() Stack() data class Stack(list):
    def __init__(self):
        self.length = 0
    def __len__(self):
        return self.length

    def push(self,x):
        self.insert(len(self),x)
        self.length += 1
    def pop(self):
        try:
            if(len(self)==0):
                raise NameError("stack is empty")
            tmp = self[len(self)-1]
            self.length -= 1
            return tmp
        except:
            print("stack is empty!!!!")
            return '#' class Stack(list):
    def __init__(self):
        self.length = 0
    def __len__(self):
        return self.length

    def push(self,x):
        self.insert(len(self),x)
        self.length += 1
    def pop(self):
        try:
            if(len(self)==0):
                raise NameError("stack is empty")
            tmp = self[len(self)-1]
            self.length -= 1
            return tmp
        except:
            print("stack is empty!!!!")
            return '#' Stack a = data.pop() data.pop() a b = data.pop() data.pop() b s = input() input() s b = data.pop() data.pop() b a = data.pop() data.pop() a
class Stack(list):
    def __init__(self):
        self.length = 0
    def __len__(self):
        return self.length

    def push(self,x):
        self.insert(len(self),x)
        self.length += 1
    def pop(self):
        try:
            if(len(self)==0):
                raise NameError("stack is empty")
            tmp = self[len(self)-1]
            self.length -= 1
            return tmp
        except:
            print("stack is empty!!!!")
            return '#'

data = Stack()
s = input()
x = s.split()

for i in x:
    if i == '+':
        a = data.pop()
        b = data.pop()
        data.push(b+a)

    elif i == '-':
        a = data.pop()
        b = data.pop()
        data.push(b-a)


    elif i == '*':
        a = data.pop()
        b = data.pop()
        data.push(b*a)
  
    else:
        data.push(int(i))
print(data.pop())