import java.io.*;
import java.util.*;

class Main {
	public static void main(String[] args) {
	    BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
	    try {
	    	Stack<Integer> stack = new Stack<Integer>();
			
		    String str = kb.readLine();
			int a, b;
		    for( String wd: str.split( " " ) ) {
			    if( "+".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a + b );			    
			    } else if( "-".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a - b );			    
			    } else if( "*".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a * b );			    
			    } else {
			    	stack.push( Integer.parseInt( wd ) );
			    }
		    }

            System.out.println( stack.pop() );
	    } catch( IOException e ) {
	        System.err.println( e );
	    }
	}
} import java.io.*; io.* java import java.util.*; util.* java class Main {
	public static void main(String[] args) {
	    BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
	    try {
	    	Stack<Integer> stack = new Stack<Integer>();
			
		    String str = kb.readLine();
			int a, b;
		    for( String wd: str.split( " " ) ) {
			    if( "+".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a + b );			    
			    } else if( "-".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a - b );			    
			    } else if( "*".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a * b );			    
			    } else {
			    	stack.push( Integer.parseInt( wd ) );
			    }
		    }

            System.out.println( stack.pop() );
	    } catch( IOException e ) {
	        System.err.println( e );
	    }
	}
} Main public static void main(String[] args) {
	    BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
	    try {
	    	Stack<Integer> stack = new Stack<Integer>();
			
		    String str = kb.readLine();
			int a, b;
		    for( String wd: str.split( " " ) ) {
			    if( "+".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a + b );			    
			    } else if( "-".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a - b );			    
			    } else if( "*".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a * b );			    
			    } else {
			    	stack.push( Integer.parseInt( wd ) );
			    }
		    }

            System.out.println( stack.pop() );
	    } catch( IOException e ) {
	        System.err.println( e );
	    }
	} main {
	    BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
	    try {
	    	Stack<Integer> stack = new Stack<Integer>();
			
		    String str = kb.readLine();
			int a, b;
		    for( String wd: str.split( " " ) ) {
			    if( "+".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a + b );			    
			    } else if( "-".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a - b );			    
			    } else if( "*".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a * b );			    
			    } else {
			    	stack.push( Integer.parseInt( wd ) );
			    }
		    }

            System.out.println( stack.pop() );
	    } catch( IOException e ) {
	        System.err.println( e );
	    }
	} BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) ); kb new BufferedReader( new InputStreamReader( System.in ) ) try {
	    	Stack<Integer> stack = new Stack<Integer>();
			
		    String str = kb.readLine();
			int a, b;
		    for( String wd: str.split( " " ) ) {
			    if( "+".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a + b );			    
			    } else if( "-".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a - b );			    
			    } else if( "*".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a * b );			    
			    } else {
			    	stack.push( Integer.parseInt( wd ) );
			    }
		    }

            System.out.println( stack.pop() );
	    } catch( IOException e ) {
	        System.err.println( e );
	    } catch( IOException e ) {
	        System.err.println( e );
	    } IOException e {
	        System.err.println( e );
	    } System.err.println( e ) System.err.println System.err System System.err e {
	    	Stack<Integer> stack = new Stack<Integer>();
			
		    String str = kb.readLine();
			int a, b;
		    for( String wd: str.split( " " ) ) {
			    if( "+".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a + b );			    
			    } else if( "-".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a - b );			    
			    } else if( "*".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a * b );			    
			    } else {
			    	stack.push( Integer.parseInt( wd ) );
			    }
		    }

            System.out.println( stack.pop() );
	    } Stack<Integer> stack = new Stack<Integer>(); stack new Stack<Integer>() String str = kb.readLine(); str kb.readLine() kb.readLine kb int a a b; b for( String wd: str.split( " " ) ) {
			    if( "+".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a + b );			    
			    } else if( "-".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a - b );			    
			    } else if( "*".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a * b );			    
			    } else {
			    	stack.push( Integer.parseInt( wd ) );
			    }
		    } String wd str.split( " " ) str.split str " " {
			    if( "+".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a + b );			    
			    } else if( "-".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a - b );			    
			    } else if( "*".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a * b );			    
			    } else {
			    	stack.push( Integer.parseInt( wd ) );
			    }
		    } {
			    if( "+".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a + b );			    
			    } else if( "-".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a - b );			    
			    } else if( "*".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a * b );			    
			    } else {
			    	stack.push( Integer.parseInt( wd ) );
			    }
		    } if( "+".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a + b );			    
			    } else if( "-".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a - b );			    
			    } else if( "*".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a * b );			    
			    } else {
			    	stack.push( Integer.parseInt( wd ) );
			    } "+".equals( wd ) "+".equals "+" wd {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a + b );			    
			    } b = stack.pop() b stack.pop() stack.pop stack a = stack.pop() a stack.pop() stack.pop stack stack.push( a + b ) stack.push stack a + b a b if( "-".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a - b );			    
			    } else if( "*".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a * b );			    
			    } else {
			    	stack.push( Integer.parseInt( wd ) );
			    } "-".equals( wd ) "-".equals "-" wd {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a - b );			    
			    } b = stack.pop() b stack.pop() stack.pop stack a = stack.pop() a stack.pop() stack.pop stack stack.push( a - b ) stack.push stack a - b a b if( "*".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a * b );			    
			    } else {
			    	stack.push( Integer.parseInt( wd ) );
			    } "*".equals( wd ) "*".equals "*" wd {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a * b );			    
			    } b = stack.pop() b stack.pop() stack.pop stack a = stack.pop() a stack.pop() stack.pop stack stack.push( a * b ) stack.push stack a * b a b {
			    	stack.push( Integer.parseInt( wd ) );
			    } stack.push( Integer.parseInt( wd ) ) stack.push stack Integer.parseInt( wd ) Integer.parseInt Integer wd System.out.println( stack.pop() ) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args
import java.io.*;
import java.util.*;

class Main {
	public static void main(String[] args) {
	    BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
	    try {
	    	Stack<Integer> stack = new Stack<Integer>();
			
		    String str = kb.readLine();
			int a, b;
		    for( String wd: str.split( " " ) ) {
			    if( "+".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a + b );			    
			    } else if( "-".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a - b );			    
			    } else if( "*".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a * b );			    
			    } else {
			    	stack.push( Integer.parseInt( wd ) );
			    }
		    }

            System.out.println( stack.pop() );
	    } catch( IOException e ) {
	        System.err.println( e );
	    }
	}
}