import java.util.*;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] linesp = new String[line.length()];
        linesp=line.split(" ");
        
        ArrayList<Integer> figure = new ArrayList<Integer>();
        int save1=0;
        int save2=0;
        
        for(int i=0;i<linesp.length;i++){       	
        	switch(linesp[i]){
        	case "+":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
				     figure.remove(figure.size()-1);
				     figure.add(save1+save2);
      		break;
        	case "-":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 figure.add(save2-save1);
    		break;        	
        	case "*":save1=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 save2=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 figure.add(save1*save2);
        	break;
        	default:figure.add(Integer.parseInt(linesp[i]));
    			break;
        	}
        }
        
        System.out.println(figure.get(0));
        
    }   
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] linesp = new String[line.length()];
        linesp=line.split(" ");
        
        ArrayList<Integer> figure = new ArrayList<Integer>();
        int save1=0;
        int save2=0;
        
        for(int i=0;i<linesp.length;i++){       	
        	switch(linesp[i]){
        	case "+":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
				     figure.remove(figure.size()-1);
				     figure.add(save1+save2);
      		break;
        	case "-":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 figure.add(save2-save1);
    		break;        	
        	case "*":save1=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 save2=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 figure.add(save1*save2);
        	break;
        	default:figure.add(Integer.parseInt(linesp[i]));
    			break;
        	}
        }
        
        System.out.println(figure.get(0));
        
    }   
} Main public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] linesp = new String[line.length()];
        linesp=line.split(" ");
        
        ArrayList<Integer> figure = new ArrayList<Integer>();
        int save1=0;
        int save2=0;
        
        for(int i=0;i<linesp.length;i++){       	
        	switch(linesp[i]){
        	case "+":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
				     figure.remove(figure.size()-1);
				     figure.add(save1+save2);
      		break;
        	case "-":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 figure.add(save2-save1);
    		break;        	
        	case "*":save1=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 save2=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 figure.add(save1*save2);
        	break;
        	default:figure.add(Integer.parseInt(linesp[i]));
    			break;
        	}
        }
        
        System.out.println(figure.get(0));
        
    } main {
    	Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] linesp = new String[line.length()];
        linesp=line.split(" ");
        
        ArrayList<Integer> figure = new ArrayList<Integer>();
        int save1=0;
        int save2=0;
        
        for(int i=0;i<linesp.length;i++){       	
        	switch(linesp[i]){
        	case "+":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
				     figure.remove(figure.size()-1);
				     figure.add(save1+save2);
      		break;
        	case "-":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 figure.add(save2-save1);
    		break;        	
        	case "*":save1=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 save2=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 figure.add(save1*save2);
        	break;
        	default:figure.add(Integer.parseInt(linesp[i]));
    			break;
        	}
        }
        
        System.out.println(figure.get(0));
        
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc String[] linesp = new String[line.length()]; linesp new String[line.length()] line.length() line.length line linesp=line.split(" ") linesp line.split(" ") line.split line " " ArrayList<Integer> figure = new ArrayList<Integer>(); figure new ArrayList<Integer>() int save1=0; save1 0 int save2=0; save2 0 for(int i=0;i<linesp.length;i++){       	
        	switch(linesp[i]){
        	case "+":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
				     figure.remove(figure.size()-1);
				     figure.add(save1+save2);
      		break;
        	case "-":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 figure.add(save2-save1);
    		break;        	
        	case "*":save1=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 save2=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 figure.add(save1*save2);
        	break;
        	default:figure.add(Integer.parseInt(linesp[i]));
    			break;
        	}
        } int i=0; int i=0; i 0 i<linesp.length i linesp.length linesp linesp.length i++ i++ i {       	
        	switch(linesp[i]){
        	case "+":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
				     figure.remove(figure.size()-1);
				     figure.add(save1+save2);
      		break;
        	case "-":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 figure.add(save2-save1);
    		break;        	
        	case "*":save1=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 save2=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 figure.add(save1*save2);
        	break;
        	default:figure.add(Integer.parseInt(linesp[i]));
    			break;
        	}
        } {       	
        	switch(linesp[i]){
        	case "+":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
				     figure.remove(figure.size()-1);
				     figure.add(save1+save2);
      		break;
        	case "-":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 figure.add(save2-save1);
    		break;        	
        	case "*":save1=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 save2=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 figure.add(save1*save2);
        	break;
        	default:figure.add(Integer.parseInt(linesp[i]));
    			break;
        	}
        } switch(linesp[i]){
        	case "+":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
				     figure.remove(figure.size()-1);
				     figure.add(save1+save2);
      		break;
        	case "-":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 figure.add(save2-save1);
    		break;        	
        	case "*":save1=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 save2=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 figure.add(save1*save2);
        	break;
        	default:figure.add(Integer.parseInt(linesp[i]));
    			break;
        	} linesp[i] linesp i case "+": "+" case "+": save1=figure.get(figure.size()-1) save1 figure.get(figure.size()-1) figure.get figure figure.size()-1 figure.size() figure.size figure 1 figure.remove(figure.size()-1) figure.remove figure figure.size()-1 figure.size() figure.size figure 1 save2=figure.get(figure.size()-1) save2 figure.get(figure.size()-1) figure.get figure figure.size()-1 figure.size() figure.size figure 1 figure.remove(figure.size()-1) figure.remove figure figure.size()-1 figure.size() figure.size figure 1 figure.add(save1+save2) figure.add figure save1+save2 save1 save2 break; case "-": "-" case "-": save1=figure.get(figure.size()-1) save1 figure.get(figure.size()-1) figure.get figure figure.size()-1 figure.size() figure.size figure 1 figure.remove(figure.size()-1) figure.remove figure figure.size()-1 figure.size() figure.size figure 1 save2=figure.get(figure.size()-1) save2 figure.get(figure.size()-1) figure.get figure figure.size()-1 figure.size() figure.size figure 1 figure.remove(figure.size()-1) figure.remove figure figure.size()-1 figure.size() figure.size figure 1 figure.add(save2-save1) figure.add figure save2-save1 save2 save1 break; case "*": "*" case "*": save1=figure.get(figure.size()-1) save1 figure.get(figure.size()-1) figure.get figure figure.size()-1 figure.size() figure.size figure 1 figure.remove(figure.size()-1) figure.remove figure figure.size()-1 figure.size() figure.size figure 1 save2=figure.get(figure.size()-1) save2 figure.get(figure.size()-1) figure.get figure figure.size()-1 figure.size() figure.size figure 1 figure.remove(figure.size()-1) figure.remove figure figure.size()-1 figure.size() figure.size figure 1 figure.add(save1*save2) figure.add figure save1*save2 save1 save2 break; default: default: figure.add(Integer.parseInt(linesp[i])) figure.add figure Integer.parseInt(linesp[i]) Integer.parseInt Integer linesp[i] linesp i break; System.out.println(figure.get(0)) System.out.println System.out System System.out figure.get(0) figure.get figure 0 String[] args args public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] linesp = new String[line.length()];
        linesp=line.split(" ");
        
        ArrayList<Integer> figure = new ArrayList<Integer>();
        int save1=0;
        int save2=0;
        
        for(int i=0;i<linesp.length;i++){       	
        	switch(linesp[i]){
        	case "+":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
				     figure.remove(figure.size()-1);
				     figure.add(save1+save2);
      		break;
        	case "-":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 figure.add(save2-save1);
    		break;        	
        	case "*":save1=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 save2=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 figure.add(save1*save2);
        	break;
        	default:figure.add(Integer.parseInt(linesp[i]));
    			break;
        	}
        }
        
        System.out.println(figure.get(0));
        
    }   
} public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] linesp = new String[line.length()];
        linesp=line.split(" ");
        
        ArrayList<Integer> figure = new ArrayList<Integer>();
        int save1=0;
        int save2=0;
        
        for(int i=0;i<linesp.length;i++){       	
        	switch(linesp[i]){
        	case "+":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
				     figure.remove(figure.size()-1);
				     figure.add(save1+save2);
      		break;
        	case "-":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 figure.add(save2-save1);
    		break;        	
        	case "*":save1=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 save2=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 figure.add(save1*save2);
        	break;
        	default:figure.add(Integer.parseInt(linesp[i]));
    			break;
        	}
        }
        
        System.out.println(figure.get(0));
        
    }   
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] linesp = new String[line.length()];
        linesp=line.split(" ");
        
        ArrayList<Integer> figure = new ArrayList<Integer>();
        int save1=0;
        int save2=0;
        
        for(int i=0;i<linesp.length;i++){       	
        	switch(linesp[i]){
        	case "+":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
				     figure.remove(figure.size()-1);
				     figure.add(save1+save2);
      		break;
        	case "-":save1=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 save2=figure.get(figure.size()-1);
					 figure.remove(figure.size()-1);
					 figure.add(save2-save1);
    		break;        	
        	case "*":save1=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 save2=figure.get(figure.size()-1);
			 		 figure.remove(figure.size()-1);
			 		 figure.add(save1*save2);
        	break;
        	default:figure.add(Integer.parseInt(linesp[i]));
    			break;
        	}
        }
        
        System.out.println(figure.get(0));
        
    }   
}