import java.util.Scanner;
import java.util.Stack;

public class Main{
	public static void main(String[] args)
	{
		Stack<Integer> s1 = new Stack<>();
		Scanner in1 = new Scanner(System.in);
		Scanner in = new Scanner(in1.nextLine());
		while(in.hasNext())
		{
			if(in.hasNextInt())
			{
				s1.push(in.nextInt());
			}else
			{
				String symbol = in.next();	
				
				if(symbol.equals("-"))
				{
					int val1 = s1.pop();
					int val2 = s1.pop();
					s1.push(val2 - val1);
				}else if(symbol.equals("+"))
				{
					s1.push(s1.pop() + s1.pop());
				}else if(symbol.equals("*"))
				{
					s1.push(s1.pop() * s1.pop());
				}
			}
			//System.out.println(s1.peek());
		}
		System.out.println(s1.pop());
		in.close();
	}
}
 import java.util.Scanner; Scanner java.util import java.util.Stack; Stack java.util public class Main{
	public static void main(String[] args)
	{
		Stack<Integer> s1 = new Stack<>();
		Scanner in1 = new Scanner(System.in);
		Scanner in = new Scanner(in1.nextLine());
		while(in.hasNext())
		{
			if(in.hasNextInt())
			{
				s1.push(in.nextInt());
			}else
			{
				String symbol = in.next();	
				
				if(symbol.equals("-"))
				{
					int val1 = s1.pop();
					int val2 = s1.pop();
					s1.push(val2 - val1);
				}else if(symbol.equals("+"))
				{
					s1.push(s1.pop() + s1.pop());
				}else if(symbol.equals("*"))
				{
					s1.push(s1.pop() * s1.pop());
				}
			}
			//System.out.println(s1.peek());
		}
		System.out.println(s1.pop());
		in.close();
	}
} Main public static void main(String[] args)
	{
		Stack<Integer> s1 = new Stack<>();
		Scanner in1 = new Scanner(System.in);
		Scanner in = new Scanner(in1.nextLine());
		while(in.hasNext())
		{
			if(in.hasNextInt())
			{
				s1.push(in.nextInt());
			}else
			{
				String symbol = in.next();	
				
				if(symbol.equals("-"))
				{
					int val1 = s1.pop();
					int val2 = s1.pop();
					s1.push(val2 - val1);
				}else if(symbol.equals("+"))
				{
					s1.push(s1.pop() + s1.pop());
				}else if(symbol.equals("*"))
				{
					s1.push(s1.pop() * s1.pop());
				}
			}
			//System.out.println(s1.peek());
		}
		System.out.println(s1.pop());
		in.close();
	} main {
		Stack<Integer> s1 = new Stack<>();
		Scanner in1 = new Scanner(System.in);
		Scanner in = new Scanner(in1.nextLine());
		while(in.hasNext())
		{
			if(in.hasNextInt())
			{
				s1.push(in.nextInt());
			}else
			{
				String symbol = in.next();	
				
				if(symbol.equals("-"))
				{
					int val1 = s1.pop();
					int val2 = s1.pop();
					s1.push(val2 - val1);
				}else if(symbol.equals("+"))
				{
					s1.push(s1.pop() + s1.pop());
				}else if(symbol.equals("*"))
				{
					s1.push(s1.pop() * s1.pop());
				}
			}
			//System.out.println(s1.peek());
		}
		System.out.println(s1.pop());
		in.close();
	} Stack<Integer> s1 = new Stack<>(); s1 new Stack<>() Scanner in1 = new Scanner(System.in); in1 new Scanner(System.in) Scanner in = new Scanner(in1.nextLine()); in new Scanner(in1.nextLine()) while(in.hasNext())
		{
			if(in.hasNextInt())
			{
				s1.push(in.nextInt());
			}else
			{
				String symbol = in.next();	
				
				if(symbol.equals("-"))
				{
					int val1 = s1.pop();
					int val2 = s1.pop();
					s1.push(val2 - val1);
				}else if(symbol.equals("+"))
				{
					s1.push(s1.pop() + s1.pop());
				}else if(symbol.equals("*"))
				{
					s1.push(s1.pop() * s1.pop());
				}
			}
			//System.out.println(s1.peek());
		} in.hasNext() in.hasNext in {
			if(in.hasNextInt())
			{
				s1.push(in.nextInt());
			}else
			{
				String symbol = in.next();	
				
				if(symbol.equals("-"))
				{
					int val1 = s1.pop();
					int val2 = s1.pop();
					s1.push(val2 - val1);
				}else if(symbol.equals("+"))
				{
					s1.push(s1.pop() + s1.pop());
				}else if(symbol.equals("*"))
				{
					s1.push(s1.pop() * s1.pop());
				}
			}
			//System.out.println(s1.peek());
		} if(in.hasNextInt())
			{
				s1.push(in.nextInt());
			}else
			{
				String symbol = in.next();	
				
				if(symbol.equals("-"))
				{
					int val1 = s1.pop();
					int val2 = s1.pop();
					s1.push(val2 - val1);
				}else if(symbol.equals("+"))
				{
					s1.push(s1.pop() + s1.pop());
				}else if(symbol.equals("*"))
				{
					s1.push(s1.pop() * s1.pop());
				}
			} in.hasNextInt() in.hasNextInt in {
				s1.push(in.nextInt());
			} s1.push(in.nextInt()) s1.push s1 in.nextInt() in.nextInt in {
				String symbol = in.next();	
				
				if(symbol.equals("-"))
				{
					int val1 = s1.pop();
					int val2 = s1.pop();
					s1.push(val2 - val1);
				}else if(symbol.equals("+"))
				{
					s1.push(s1.pop() + s1.pop());
				}else if(symbol.equals("*"))
				{
					s1.push(s1.pop() * s1.pop());
				}
			} String symbol = in.next(); symbol in.next() in.next in if(symbol.equals("-"))
				{
					int val1 = s1.pop();
					int val2 = s1.pop();
					s1.push(val2 - val1);
				}else if(symbol.equals("+"))
				{
					s1.push(s1.pop() + s1.pop());
				}else if(symbol.equals("*"))
				{
					s1.push(s1.pop() * s1.pop());
				} symbol.equals("-") symbol.equals symbol "-" {
					int val1 = s1.pop();
					int val2 = s1.pop();
					s1.push(val2 - val1);
				} int val1 = s1.pop(); val1 s1.pop() s1.pop s1 int val2 = s1.pop(); val2 s1.pop() s1.pop s1 s1.push(val2 - val1) s1.push s1 val2 - val1 val2 val1 if(symbol.equals("+"))
				{
					s1.push(s1.pop() + s1.pop());
				}else if(symbol.equals("*"))
				{
					s1.push(s1.pop() * s1.pop());
				} symbol.equals("+") symbol.equals symbol "+" {
					s1.push(s1.pop() + s1.pop());
				} s1.push(s1.pop() + s1.pop()) s1.push s1 s1.pop() + s1.pop() s1.pop() s1.pop s1 s1.pop() s1.pop s1 if(symbol.equals("*"))
				{
					s1.push(s1.pop() * s1.pop());
				} symbol.equals("*") symbol.equals symbol "*" {
					s1.push(s1.pop() * s1.pop());
				} s1.push(s1.pop() * s1.pop()) s1.push s1 s1.pop() * s1.pop() s1.pop() s1.pop s1 s1.pop() s1.pop s1 System.out.println(s1.pop()) System.out.println System.out System System.out s1.pop() s1.pop s1 in.close() in.close in String[] args args public class Main{
	public static void main(String[] args)
	{
		Stack<Integer> s1 = new Stack<>();
		Scanner in1 = new Scanner(System.in);
		Scanner in = new Scanner(in1.nextLine());
		while(in.hasNext())
		{
			if(in.hasNextInt())
			{
				s1.push(in.nextInt());
			}else
			{
				String symbol = in.next();	
				
				if(symbol.equals("-"))
				{
					int val1 = s1.pop();
					int val2 = s1.pop();
					s1.push(val2 - val1);
				}else if(symbol.equals("+"))
				{
					s1.push(s1.pop() + s1.pop());
				}else if(symbol.equals("*"))
				{
					s1.push(s1.pop() * s1.pop());
				}
			}
			//System.out.println(s1.peek());
		}
		System.out.println(s1.pop());
		in.close();
	}
} public class Main{
	public static void main(String[] args)
	{
		Stack<Integer> s1 = new Stack<>();
		Scanner in1 = new Scanner(System.in);
		Scanner in = new Scanner(in1.nextLine());
		while(in.hasNext())
		{
			if(in.hasNextInt())
			{
				s1.push(in.nextInt());
			}else
			{
				String symbol = in.next();	
				
				if(symbol.equals("-"))
				{
					int val1 = s1.pop();
					int val2 = s1.pop();
					s1.push(val2 - val1);
				}else if(symbol.equals("+"))
				{
					s1.push(s1.pop() + s1.pop());
				}else if(symbol.equals("*"))
				{
					s1.push(s1.pop() * s1.pop());
				}
			}
			//System.out.println(s1.peek());
		}
		System.out.println(s1.pop());
		in.close();
	}
} Main
import java.util.Scanner;
import java.util.Stack;

public class Main{
	public static void main(String[] args)
	{
		Stack<Integer> s1 = new Stack<>();
		Scanner in1 = new Scanner(System.in);
		Scanner in = new Scanner(in1.nextLine());
		while(in.hasNext())
		{
			if(in.hasNextInt())
			{
				s1.push(in.nextInt());
			}else
			{
				String symbol = in.next();	
				
				if(symbol.equals("-"))
				{
					int val1 = s1.pop();
					int val2 = s1.pop();
					s1.push(val2 - val1);
				}else if(symbol.equals("+"))
				{
					s1.push(s1.pop() + s1.pop());
				}else if(symbol.equals("*"))
				{
					s1.push(s1.pop() * s1.pop());
				}
			}
			//System.out.println(s1.peek());
		}
		System.out.println(s1.pop());
		in.close();
	}
}

