#include <iostream>                                                                                   
#include <vector>                                                                                     
#include <sstream>                                                                                    
                                                                                                      
using namespace std;                                                                                  
                                                                                                      
int main()                                                                                            
{                                                                                                     
  int n;                                                                                              
  string s;                                                                                           
  vector<int> stack;                                                                                  
  for(;cin>>s;)                                                                                       
    {                                                                                                 
      if(s[0]>='0' && s[0]<='9')                                                                      
        {                                                                                             
          int tmp;                                                                                    
          stringstream ss;                                                                            
          ss<<s;                                                                                      
          ss>>tmp;                                                                                    
          stack.push_back(tmp);                                                                       
          //      cout<<"push :"<<tmp<<endl;                                                          
        }                                                                                             
      else                                                                                            
        {                                                                                             
          int b=stack.back();                                                                         
          stack.pop_back();                                                                           
          int a=stack.back();                                                                         
          stack.pop_back();                                                                           
          if(s[0]=='+')                                                                               
            {                                                                                         
              stack.push_back(a+b);                                                                   
              //    cout<<"push :"<<a <<"+"<<b<<"="<<a+b<<endl;                                       
            }                                                                                         
          else if(s[0]=='-')                                                                          
            {                                                                                         
            stack.push_back(a-b);                                                                     
            //   cout<<"push :"<<a <<"-"<<b<<"="<<a-b<<endl;     
            }                                                                                         
          else if(s[0]=='*')                                                                          
            {                                                                                         
              stack.push_back(a*b);                                                                   
              //  cout<<"push :"<<a <<"*"<<b<<"="<<a*b<<endl;                                         
            }                                                                                         
        }                                                                                             
      //      cout<<s<<endl;                                                                          
    }                                                                                                 
      cout<<stack[0]<<endl;                                                                           
}                                                                                                     

Measured memory_bytes: 1244