import java.io.*;
import java.util.Deque;
import java.util.ArrayDeque;

public class Main
{
	public static void main(String[] args)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Deque<Integer> stack = new ArrayDeque<>();
		String[] str = br.readLine().split(" ");
		int a,b;
		/*for(int i = 0; i < str.length ; i++){
			System.out.println(str[i]);
		}*/
		for(int i = 0; i < str.length ; i++)
		{
			switch(str[i])
			{
			case "+":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b+a);
				//System.out.println("a+b"+a+" "+b+""+(a+b));
				
				break;
			case "-":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b-a);
				//System.out.println("b-a"+b+" "+a+" "+(b-a));
				
				break;
			case "*":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(a*b);
				//System.out.println("a*b"+a+" "+b+""+(a*b));
				
				break;
					
			default :
				stack.offer(Integer.parseInt(str[i]));
				break;
			}
		}
		
		System.out.println(stack.poll());
		
	}
} import java.io.*; io.* java import java.util.Deque; Deque java.util import java.util.ArrayDeque; ArrayDeque java.util public class Main
{
	public static void main(String[] args)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Deque<Integer> stack = new ArrayDeque<>();
		String[] str = br.readLine().split(" ");
		int a,b;
		/*for(int i = 0; i < str.length ; i++){
			System.out.println(str[i]);
		}*/
		for(int i = 0; i < str.length ; i++)
		{
			switch(str[i])
			{
			case "+":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b+a);
				//System.out.println("a+b"+a+" "+b+""+(a+b));
				
				break;
			case "-":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b-a);
				//System.out.println("b-a"+b+" "+a+" "+(b-a));
				
				break;
			case "*":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(a*b);
				//System.out.println("a*b"+a+" "+b+""+(a*b));
				
				break;
					
			default :
				stack.offer(Integer.parseInt(str[i]));
				break;
			}
		}
		
		System.out.println(stack.poll());
		
	}
} Main public static void main(String[] args)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Deque<Integer> stack = new ArrayDeque<>();
		String[] str = br.readLine().split(" ");
		int a,b;
		/*for(int i = 0; i < str.length ; i++){
			System.out.println(str[i]);
		}*/
		for(int i = 0; i < str.length ; i++)
		{
			switch(str[i])
			{
			case "+":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b+a);
				//System.out.println("a+b"+a+" "+b+""+(a+b));
				
				break;
			case "-":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b-a);
				//System.out.println("b-a"+b+" "+a+" "+(b-a));
				
				break;
			case "*":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(a*b);
				//System.out.println("a*b"+a+" "+b+""+(a*b));
				
				break;
					
			default :
				stack.offer(Integer.parseInt(str[i]));
				break;
			}
		}
		
		System.out.println(stack.poll());
		
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Deque<Integer> stack = new ArrayDeque<>();
		String[] str = br.readLine().split(" ");
		int a,b;
		/*for(int i = 0; i < str.length ; i++){
			System.out.println(str[i]);
		}*/
		for(int i = 0; i < str.length ; i++)
		{
			switch(str[i])
			{
			case "+":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b+a);
				//System.out.println("a+b"+a+" "+b+""+(a+b));
				
				break;
			case "-":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b-a);
				//System.out.println("b-a"+b+" "+a+" "+(b-a));
				
				break;
			case "*":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(a*b);
				//System.out.println("a*b"+a+" "+b+""+(a*b));
				
				break;
					
			default :
				stack.offer(Integer.parseInt(str[i]));
				break;
			}
		}
		
		System.out.println(stack.poll());
		
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) Deque<Integer> stack = new ArrayDeque<>(); stack new ArrayDeque<>() String[] str = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int a a b; b for(int i = 0; i < str.length ; i++)
		{
			switch(str[i])
			{
			case "+":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b+a);
				//System.out.println("a+b"+a+" "+b+""+(a+b));
				
				break;
			case "-":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b-a);
				//System.out.println("b-a"+b+" "+a+" "+(b-a));
				
				break;
			case "*":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(a*b);
				//System.out.println("a*b"+a+" "+b+""+(a*b));
				
				break;
					
			default :
				stack.offer(Integer.parseInt(str[i]));
				break;
			}
		} int i = 0; int i = 0; i 0 i < str.length i str.length str str.length i++ i++ i {
			switch(str[i])
			{
			case "+":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b+a);
				//System.out.println("a+b"+a+" "+b+""+(a+b));
				
				break;
			case "-":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b-a);
				//System.out.println("b-a"+b+" "+a+" "+(b-a));
				
				break;
			case "*":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(a*b);
				//System.out.println("a*b"+a+" "+b+""+(a*b));
				
				break;
					
			default :
				stack.offer(Integer.parseInt(str[i]));
				break;
			}
		} {
			switch(str[i])
			{
			case "+":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b+a);
				//System.out.println("a+b"+a+" "+b+""+(a+b));
				
				break;
			case "-":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b-a);
				//System.out.println("b-a"+b+" "+a+" "+(b-a));
				
				break;
			case "*":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(a*b);
				//System.out.println("a*b"+a+" "+b+""+(a*b));
				
				break;
					
			default :
				stack.offer(Integer.parseInt(str[i]));
				break;
			}
		} switch(str[i])
			{
			case "+":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b+a);
				//System.out.println("a+b"+a+" "+b+""+(a+b));
				
				break;
			case "-":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b-a);
				//System.out.println("b-a"+b+" "+a+" "+(b-a));
				
				break;
			case "*":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(a*b);
				//System.out.println("a*b"+a+" "+b+""+(a*b));
				
				break;
					
			default :
				stack.offer(Integer.parseInt(str[i]));
				break;
			} str[i] str i case "+": "+" case "+": a = stack.pollLast() a stack.pollLast() stack.pollLast stack b = stack.pollLast() b stack.pollLast() stack.pollLast stack stack.offer(b+a) stack.offer stack b+a b a break; case "-": "-" case "-": a = stack.pollLast() a stack.pollLast() stack.pollLast stack b = stack.pollLast() b stack.pollLast() stack.pollLast stack stack.offer(b-a) stack.offer stack b-a b a break; case "*": "*" case "*": a = stack.pollLast() a stack.pollLast() stack.pollLast stack b = stack.pollLast() b stack.pollLast() stack.pollLast stack stack.offer(a*b) stack.offer stack a*b a b break; default : default : stack.offer(Integer.parseInt(str[i])) stack.offer stack Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i break; 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)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Deque<Integer> stack = new ArrayDeque<>();
		String[] str = br.readLine().split(" ");
		int a,b;
		/*for(int i = 0; i < str.length ; i++){
			System.out.println(str[i]);
		}*/
		for(int i = 0; i < str.length ; i++)
		{
			switch(str[i])
			{
			case "+":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b+a);
				//System.out.println("a+b"+a+" "+b+""+(a+b));
				
				break;
			case "-":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b-a);
				//System.out.println("b-a"+b+" "+a+" "+(b-a));
				
				break;
			case "*":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(a*b);
				//System.out.println("a*b"+a+" "+b+""+(a*b));
				
				break;
					
			default :
				stack.offer(Integer.parseInt(str[i]));
				break;
			}
		}
		
		System.out.println(stack.poll());
		
	}
} public class Main
{
	public static void main(String[] args)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Deque<Integer> stack = new ArrayDeque<>();
		String[] str = br.readLine().split(" ");
		int a,b;
		/*for(int i = 0; i < str.length ; i++){
			System.out.println(str[i]);
		}*/
		for(int i = 0; i < str.length ; i++)
		{
			switch(str[i])
			{
			case "+":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b+a);
				//System.out.println("a+b"+a+" "+b+""+(a+b));
				
				break;
			case "-":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b-a);
				//System.out.println("b-a"+b+" "+a+" "+(b-a));
				
				break;
			case "*":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(a*b);
				//System.out.println("a*b"+a+" "+b+""+(a*b));
				
				break;
					
			default :
				stack.offer(Integer.parseInt(str[i]));
				break;
			}
		}
		
		System.out.println(stack.poll());
		
	}
} Main
import java.io.*;
import java.util.Deque;
import java.util.ArrayDeque;

public class Main
{
	public static void main(String[] args)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Deque<Integer> stack = new ArrayDeque<>();
		String[] str = br.readLine().split(" ");
		int a,b;
		/*for(int i = 0; i < str.length ; i++){
			System.out.println(str[i]);
		}*/
		for(int i = 0; i < str.length ; i++)
		{
			switch(str[i])
			{
			case "+":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b+a);
				//System.out.println("a+b"+a+" "+b+""+(a+b));
				
				break;
			case "-":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b-a);
				//System.out.println("b-a"+b+" "+a+" "+(b-a));
				
				break;
			case "*":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(a*b);
				//System.out.println("a*b"+a+" "+b+""+(a*b));
				
				break;
					
			default :
				stack.offer(Integer.parseInt(str[i]));
				break;
			}
		}
		
		System.out.println(stack.poll());
		
	}
}