

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

public class Main {
	public static void main(String[] args) {
		Stack<Integer> stack = new Stack<Integer>();
		Scanner sc = new Scanner(System.in);
		
		String line = sc.nextLine();
		String[] str = line.split(" ");
		
//		for(int i=0;i<str.length;i++)
//		{
//			System.out.println(str[i]);
//		}
		
		for(int i=0;i<str.length;i++)
		{
			if(str[i].equals("+"))
			{
				int ans = stack.pop()+stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("-"))
			{
				//不能直接减除
				int a = stack.pop();
				int b = stack.pop();
				int ans = b-a;
				//int ans = stack.pop()-stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("*"))
			{
				int ans = stack.pop()*stack.pop();
				stack.push(ans);
			}
			else
			{
				stack.push(Integer.parseInt(str[i]));
			}
		}
		System.out.println(stack.pop());
		
	}
}
 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> stack = new Stack<Integer>();
		Scanner sc = new Scanner(System.in);
		
		String line = sc.nextLine();
		String[] str = line.split(" ");
		
//		for(int i=0;i<str.length;i++)
//		{
//			System.out.println(str[i]);
//		}
		
		for(int i=0;i<str.length;i++)
		{
			if(str[i].equals("+"))
			{
				int ans = stack.pop()+stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("-"))
			{
				//不能直接减除
				int a = stack.pop();
				int b = stack.pop();
				int ans = b-a;
				//int ans = stack.pop()-stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("*"))
			{
				int ans = stack.pop()*stack.pop();
				stack.push(ans);
			}
			else
			{
				stack.push(Integer.parseInt(str[i]));
			}
		}
		System.out.println(stack.pop());
		
	}
} Main public static void main(String[] args) {
		Stack<Integer> stack = new Stack<Integer>();
		Scanner sc = new Scanner(System.in);
		
		String line = sc.nextLine();
		String[] str = line.split(" ");
		
//		for(int i=0;i<str.length;i++)
//		{
//			System.out.println(str[i]);
//		}
		
		for(int i=0;i<str.length;i++)
		{
			if(str[i].equals("+"))
			{
				int ans = stack.pop()+stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("-"))
			{
				//不能直接减除
				int a = stack.pop();
				int b = stack.pop();
				int ans = b-a;
				//int ans = stack.pop()-stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("*"))
			{
				int ans = stack.pop()*stack.pop();
				stack.push(ans);
			}
			else
			{
				stack.push(Integer.parseInt(str[i]));
			}
		}
		System.out.println(stack.pop());
		
	} main {
		Stack<Integer> stack = new Stack<Integer>();
		Scanner sc = new Scanner(System.in);
		
		String line = sc.nextLine();
		String[] str = line.split(" ");
		
//		for(int i=0;i<str.length;i++)
//		{
//			System.out.println(str[i]);
//		}
		
		for(int i=0;i<str.length;i++)
		{
			if(str[i].equals("+"))
			{
				int ans = stack.pop()+stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("-"))
			{
				//不能直接减除
				int a = stack.pop();
				int b = stack.pop();
				int ans = b-a;
				//int ans = stack.pop()-stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("*"))
			{
				int ans = stack.pop()*stack.pop();
				stack.push(ans);
			}
			else
			{
				stack.push(Integer.parseInt(str[i]));
			}
		}
		System.out.println(stack.pop());
		
	} Stack<Integer> stack = new Stack<Integer>(); stack new Stack<Integer>() Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc String[] str = line.split(" "); str line.split(" ") line.split line " " for(int i=0;i<str.length;i++)
		{
			if(str[i].equals("+"))
			{
				int ans = stack.pop()+stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("-"))
			{
				//不能直接减除
				int a = stack.pop();
				int b = stack.pop();
				int ans = b-a;
				//int ans = stack.pop()-stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("*"))
			{
				int ans = stack.pop()*stack.pop();
				stack.push(ans);
			}
			else
			{
				stack.push(Integer.parseInt(str[i]));
			}
		} int i=0; int i=0; i 0 i<str.length i str.length str str.length i++ i++ i {
			if(str[i].equals("+"))
			{
				int ans = stack.pop()+stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("-"))
			{
				//不能直接减除
				int a = stack.pop();
				int b = stack.pop();
				int ans = b-a;
				//int ans = stack.pop()-stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("*"))
			{
				int ans = stack.pop()*stack.pop();
				stack.push(ans);
			}
			else
			{
				stack.push(Integer.parseInt(str[i]));
			}
		} {
			if(str[i].equals("+"))
			{
				int ans = stack.pop()+stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("-"))
			{
				//不能直接减除
				int a = stack.pop();
				int b = stack.pop();
				int ans = b-a;
				//int ans = stack.pop()-stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("*"))
			{
				int ans = stack.pop()*stack.pop();
				stack.push(ans);
			}
			else
			{
				stack.push(Integer.parseInt(str[i]));
			}
		} if(str[i].equals("+"))
			{
				int ans = stack.pop()+stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("-"))
			{
				//不能直接减除
				int a = stack.pop();
				int b = stack.pop();
				int ans = b-a;
				//int ans = stack.pop()-stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("*"))
			{
				int ans = stack.pop()*stack.pop();
				stack.push(ans);
			}
			else
			{
				stack.push(Integer.parseInt(str[i]));
			} str[i].equals("+") str[i].equals str[i] str i "+" {
				int ans = stack.pop()+stack.pop();
				stack.push(ans);
			} int ans = stack.pop()+stack.pop(); ans stack.pop()+stack.pop() stack.pop() stack.pop stack stack.pop() stack.pop stack stack.push(ans) stack.push stack ans if(str[i].equals("-"))
			{
				//不能直接减除
				int a = stack.pop();
				int b = stack.pop();
				int ans = b-a;
				//int ans = stack.pop()-stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("*"))
			{
				int ans = stack.pop()*stack.pop();
				stack.push(ans);
			}
			else
			{
				stack.push(Integer.parseInt(str[i]));
			} str[i].equals("-") str[i].equals str[i] str i "-" {
				//不能直接减除
				int a = stack.pop();
				int b = stack.pop();
				int ans = b-a;
				//int ans = stack.pop()-stack.pop();
				stack.push(ans);
			} int a = stack.pop(); a stack.pop() stack.pop stack int b = stack.pop(); b stack.pop() stack.pop stack int ans = b-a; ans b-a b a stack.push(ans) stack.push stack ans if(str[i].equals("*"))
			{
				int ans = stack.pop()*stack.pop();
				stack.push(ans);
			}
			else
			{
				stack.push(Integer.parseInt(str[i]));
			} str[i].equals("*") str[i].equals str[i] str i "*" {
				int ans = stack.pop()*stack.pop();
				stack.push(ans);
			} int ans = stack.pop()*stack.pop(); ans stack.pop()*stack.pop() stack.pop() stack.pop stack stack.pop() stack.pop stack stack.push(ans) stack.push stack ans {
				stack.push(Integer.parseInt(str[i]));
			} stack.push(Integer.parseInt(str[i])) stack.push stack Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args public class Main {
	public static void main(String[] args) {
		Stack<Integer> stack = new Stack<Integer>();
		Scanner sc = new Scanner(System.in);
		
		String line = sc.nextLine();
		String[] str = line.split(" ");
		
//		for(int i=0;i<str.length;i++)
//		{
//			System.out.println(str[i]);
//		}
		
		for(int i=0;i<str.length;i++)
		{
			if(str[i].equals("+"))
			{
				int ans = stack.pop()+stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("-"))
			{
				//不能直接减除
				int a = stack.pop();
				int b = stack.pop();
				int ans = b-a;
				//int ans = stack.pop()-stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("*"))
			{
				int ans = stack.pop()*stack.pop();
				stack.push(ans);
			}
			else
			{
				stack.push(Integer.parseInt(str[i]));
			}
		}
		System.out.println(stack.pop());
		
	}
} public class Main {
	public static void main(String[] args) {
		Stack<Integer> stack = new Stack<Integer>();
		Scanner sc = new Scanner(System.in);
		
		String line = sc.nextLine();
		String[] str = line.split(" ");
		
//		for(int i=0;i<str.length;i++)
//		{
//			System.out.println(str[i]);
//		}
		
		for(int i=0;i<str.length;i++)
		{
			if(str[i].equals("+"))
			{
				int ans = stack.pop()+stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("-"))
			{
				//不能直接减除
				int a = stack.pop();
				int b = stack.pop();
				int ans = b-a;
				//int ans = stack.pop()-stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("*"))
			{
				int ans = stack.pop()*stack.pop();
				stack.push(ans);
			}
			else
			{
				stack.push(Integer.parseInt(str[i]));
			}
		}
		System.out.println(stack.pop());
		
	}
} Main


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

public class Main {
	public static void main(String[] args) {
		Stack<Integer> stack = new Stack<Integer>();
		Scanner sc = new Scanner(System.in);
		
		String line = sc.nextLine();
		String[] str = line.split(" ");
		
//		for(int i=0;i<str.length;i++)
//		{
//			System.out.println(str[i]);
//		}
		
		for(int i=0;i<str.length;i++)
		{
			if(str[i].equals("+"))
			{
				int ans = stack.pop()+stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("-"))
			{
				//不能直接减除
				int a = stack.pop();
				int b = stack.pop();
				int ans = b-a;
				//int ans = stack.pop()-stack.pop();
				stack.push(ans);
			}
			else if(str[i].equals("*"))
			{
				int ans = stack.pop()*stack.pop();
				stack.push(ans);
			}
			else
			{
				stack.push(Integer.parseInt(str[i]));
			}
		}
		System.out.println(stack.pop());
		
	}
}

