import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Scanner;

public class Main {
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		LinkedList<String> input = new LinkedList<String>();
		while(sc.hasNext()){
			input.addLast(sc.next());
		}
		
		LinkedList<Integer> stack = new LinkedList<Integer>();
		while(!input.isEmpty()){
			String ops = input.poll();
			
			if("+".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b + a);				
			}else if("-".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b - a);
			}else if("*".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b * a);
			}else if("/".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b / a);
			}else{
				stack.addFirst(Integer.parseInt(ops));
			}
		}
		
		System.out.println(stack.poll());
		
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.LinkedList; LinkedList java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util public class Main {
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		LinkedList<String> input = new LinkedList<String>();
		while(sc.hasNext()){
			input.addLast(sc.next());
		}
		
		LinkedList<Integer> stack = new LinkedList<Integer>();
		while(!input.isEmpty()){
			String ops = input.poll();
			
			if("+".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b + a);				
			}else if("-".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b - a);
			}else if("*".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b * a);
			}else if("/".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b / a);
			}else{
				stack.addFirst(Integer.parseInt(ops));
			}
		}
		
		System.out.println(stack.poll());
		
	}
} Main public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		LinkedList<String> input = new LinkedList<String>();
		while(sc.hasNext()){
			input.addLast(sc.next());
		}
		
		LinkedList<Integer> stack = new LinkedList<Integer>();
		while(!input.isEmpty()){
			String ops = input.poll();
			
			if("+".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b + a);				
			}else if("-".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b - a);
			}else if("*".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b * a);
			}else if("/".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b / a);
			}else{
				stack.addFirst(Integer.parseInt(ops));
			}
		}
		
		System.out.println(stack.poll());
		
	} main {
		Scanner sc = new Scanner(System.in);
		
		LinkedList<String> input = new LinkedList<String>();
		while(sc.hasNext()){
			input.addLast(sc.next());
		}
		
		LinkedList<Integer> stack = new LinkedList<Integer>();
		while(!input.isEmpty()){
			String ops = input.poll();
			
			if("+".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b + a);				
			}else if("-".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b - a);
			}else if("*".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b * a);
			}else if("/".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b / a);
			}else{
				stack.addFirst(Integer.parseInt(ops));
			}
		}
		
		System.out.println(stack.poll());
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) LinkedList<String> input = new LinkedList<String>(); input new LinkedList<String>() while(sc.hasNext()){
			input.addLast(sc.next());
		} sc.hasNext() sc.hasNext sc {
			input.addLast(sc.next());
		} input.addLast(sc.next()) input.addLast input sc.next() sc.next sc LinkedList<Integer> stack = new LinkedList<Integer>(); stack new LinkedList<Integer>() while(!input.isEmpty()){
			String ops = input.poll();
			
			if("+".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b + a);				
			}else if("-".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b - a);
			}else if("*".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b * a);
			}else if("/".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b / a);
			}else{
				stack.addFirst(Integer.parseInt(ops));
			}
		} !input.isEmpty() input.isEmpty() input.isEmpty input {
			String ops = input.poll();
			
			if("+".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b + a);				
			}else if("-".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b - a);
			}else if("*".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b * a);
			}else if("/".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b / a);
			}else{
				stack.addFirst(Integer.parseInt(ops));
			}
		} String ops = input.poll(); ops input.poll() input.poll input if("+".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b + a);				
			}else if("-".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b - a);
			}else if("*".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b * a);
			}else if("/".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b / a);
			}else{
				stack.addFirst(Integer.parseInt(ops));
			} "+".equals(ops) "+".equals "+" ops {
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b + a);				
			} final int a = stack.poll(); a stack.poll() stack.poll stack final int b = stack.poll(); b stack.poll() stack.poll stack stack.addFirst(b + a) stack.addFirst stack b + a b a if("-".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b - a);
			}else if("*".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b * a);
			}else if("/".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b / a);
			}else{
				stack.addFirst(Integer.parseInt(ops));
			} "-".equals(ops) "-".equals "-" ops {
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b - a);
			} final int a = stack.poll(); a stack.poll() stack.poll stack final int b = stack.poll(); b stack.poll() stack.poll stack stack.addFirst(b - a) stack.addFirst stack b - a b a if("*".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b * a);
			}else if("/".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b / a);
			}else{
				stack.addFirst(Integer.parseInt(ops));
			} "*".equals(ops) "*".equals "*" ops {
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b * a);
			} final int a = stack.poll(); a stack.poll() stack.poll stack final int b = stack.poll(); b stack.poll() stack.poll stack stack.addFirst(b * a) stack.addFirst stack b * a b a if("/".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b / a);
			}else{
				stack.addFirst(Integer.parseInt(ops));
			} "/".equals(ops) "/".equals "/" ops {
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b / a);
			} final int a = stack.poll(); a stack.poll() stack.poll stack final int b = stack.poll(); b stack.poll() stack.poll stack stack.addFirst(b / a) stack.addFirst stack b / a b a {
				stack.addFirst(Integer.parseInt(ops));
			} stack.addFirst(Integer.parseInt(ops)) stack.addFirst stack Integer.parseInt(ops) Integer.parseInt Integer ops System.out.println(stack.poll()) System.out.println System.out System System.out stack.poll() stack.poll stack String args[] args public class Main {
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		LinkedList<String> input = new LinkedList<String>();
		while(sc.hasNext()){
			input.addLast(sc.next());
		}
		
		LinkedList<Integer> stack = new LinkedList<Integer>();
		while(!input.isEmpty()){
			String ops = input.poll();
			
			if("+".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b + a);				
			}else if("-".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b - a);
			}else if("*".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b * a);
			}else if("/".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b / a);
			}else{
				stack.addFirst(Integer.parseInt(ops));
			}
		}
		
		System.out.println(stack.poll());
		
	}
} public class Main {
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		LinkedList<String> input = new LinkedList<String>();
		while(sc.hasNext()){
			input.addLast(sc.next());
		}
		
		LinkedList<Integer> stack = new LinkedList<Integer>();
		while(!input.isEmpty()){
			String ops = input.poll();
			
			if("+".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b + a);				
			}else if("-".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b - a);
			}else if("*".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b * a);
			}else if("/".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b / a);
			}else{
				stack.addFirst(Integer.parseInt(ops));
			}
		}
		
		System.out.println(stack.poll());
		
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Scanner;

public class Main {
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		LinkedList<String> input = new LinkedList<String>();
		while(sc.hasNext()){
			input.addLast(sc.next());
		}
		
		LinkedList<Integer> stack = new LinkedList<Integer>();
		while(!input.isEmpty()){
			String ops = input.poll();
			
			if("+".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b + a);				
			}else if("-".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b - a);
			}else if("*".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b * a);
			}else if("/".equals(ops)){
				final int a = stack.poll();
				final int b = stack.poll();
				stack.addFirst(b / a);
			}else{
				stack.addFirst(Integer.parseInt(ops));
			}
		}
		
		System.out.println(stack.poll());
		
	}
}