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

public class Main {
	
	public static int RPN(ArrayList<String> in) {
		int output = 0;
		String ops = "+-/*";
		Stack<String> nums = new Stack<>();
		
		for (String s : in) {
			if (!ops.contains(s)) {
				nums.push(s);
			} else {
				int b = Integer.parseInt(nums.pop());
				int a = Integer.parseInt(nums.pop());
				int op = ops.indexOf(s);
				if (op == 0) {
					nums.push(String.valueOf(a + b));
				} else if (op == 1) {
					nums.push(String.valueOf(a - b));
				} else if (op == 2) {
					nums.push(String.valueOf(a / b));
				} else if (op == 3) {
					nums.push(String.valueOf(a * b));
				}
				
			}
		}
		output = Integer.parseInt(nums.pop());
		
		return output;
	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		ArrayList<String> input = new ArrayList<>();
		
		while (in.hasNext()) {
			input.add(in.next().trim());
		}
		System.out.println(RPN(input));
		
		in.close();
	}
}
 import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util import java.util.Stack; Stack java.util public class Main {
	
	public static int RPN(ArrayList<String> in) {
		int output = 0;
		String ops = "+-/*";
		Stack<String> nums = new Stack<>();
		
		for (String s : in) {
			if (!ops.contains(s)) {
				nums.push(s);
			} else {
				int b = Integer.parseInt(nums.pop());
				int a = Integer.parseInt(nums.pop());
				int op = ops.indexOf(s);
				if (op == 0) {
					nums.push(String.valueOf(a + b));
				} else if (op == 1) {
					nums.push(String.valueOf(a - b));
				} else if (op == 2) {
					nums.push(String.valueOf(a / b));
				} else if (op == 3) {
					nums.push(String.valueOf(a * b));
				}
				
			}
		}
		output = Integer.parseInt(nums.pop());
		
		return output;
	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		ArrayList<String> input = new ArrayList<>();
		
		while (in.hasNext()) {
			input.add(in.next().trim());
		}
		System.out.println(RPN(input));
		
		in.close();
	}
} Main public static int RPN(ArrayList<String> in) {
		int output = 0;
		String ops = "+-/*";
		Stack<String> nums = new Stack<>();
		
		for (String s : in) {
			if (!ops.contains(s)) {
				nums.push(s);
			} else {
				int b = Integer.parseInt(nums.pop());
				int a = Integer.parseInt(nums.pop());
				int op = ops.indexOf(s);
				if (op == 0) {
					nums.push(String.valueOf(a + b));
				} else if (op == 1) {
					nums.push(String.valueOf(a - b));
				} else if (op == 2) {
					nums.push(String.valueOf(a / b));
				} else if (op == 3) {
					nums.push(String.valueOf(a * b));
				}
				
			}
		}
		output = Integer.parseInt(nums.pop());
		
		return output;
	} RPN {
		int output = 0;
		String ops = "+-/*";
		Stack<String> nums = new Stack<>();
		
		for (String s : in) {
			if (!ops.contains(s)) {
				nums.push(s);
			} else {
				int b = Integer.parseInt(nums.pop());
				int a = Integer.parseInt(nums.pop());
				int op = ops.indexOf(s);
				if (op == 0) {
					nums.push(String.valueOf(a + b));
				} else if (op == 1) {
					nums.push(String.valueOf(a - b));
				} else if (op == 2) {
					nums.push(String.valueOf(a / b));
				} else if (op == 3) {
					nums.push(String.valueOf(a * b));
				}
				
			}
		}
		output = Integer.parseInt(nums.pop());
		
		return output;
	} int output = 0; output 0 String ops = "+-/*"; ops "+-/*" Stack<String> nums = new Stack<>(); nums new Stack<>() for (String s : in) {
			if (!ops.contains(s)) {
				nums.push(s);
			} else {
				int b = Integer.parseInt(nums.pop());
				int a = Integer.parseInt(nums.pop());
				int op = ops.indexOf(s);
				if (op == 0) {
					nums.push(String.valueOf(a + b));
				} else if (op == 1) {
					nums.push(String.valueOf(a - b));
				} else if (op == 2) {
					nums.push(String.valueOf(a / b));
				} else if (op == 3) {
					nums.push(String.valueOf(a * b));
				}
				
			}
		} String s in {
			if (!ops.contains(s)) {
				nums.push(s);
			} else {
				int b = Integer.parseInt(nums.pop());
				int a = Integer.parseInt(nums.pop());
				int op = ops.indexOf(s);
				if (op == 0) {
					nums.push(String.valueOf(a + b));
				} else if (op == 1) {
					nums.push(String.valueOf(a - b));
				} else if (op == 2) {
					nums.push(String.valueOf(a / b));
				} else if (op == 3) {
					nums.push(String.valueOf(a * b));
				}
				
			}
		} {
			if (!ops.contains(s)) {
				nums.push(s);
			} else {
				int b = Integer.parseInt(nums.pop());
				int a = Integer.parseInt(nums.pop());
				int op = ops.indexOf(s);
				if (op == 0) {
					nums.push(String.valueOf(a + b));
				} else if (op == 1) {
					nums.push(String.valueOf(a - b));
				} else if (op == 2) {
					nums.push(String.valueOf(a / b));
				} else if (op == 3) {
					nums.push(String.valueOf(a * b));
				}
				
			}
		} if (!ops.contains(s)) {
				nums.push(s);
			} else {
				int b = Integer.parseInt(nums.pop());
				int a = Integer.parseInt(nums.pop());
				int op = ops.indexOf(s);
				if (op == 0) {
					nums.push(String.valueOf(a + b));
				} else if (op == 1) {
					nums.push(String.valueOf(a - b));
				} else if (op == 2) {
					nums.push(String.valueOf(a / b));
				} else if (op == 3) {
					nums.push(String.valueOf(a * b));
				}
				
			} !ops.contains(s) ops.contains(s) ops.contains ops s {
				nums.push(s);
			} nums.push(s) nums.push nums s {
				int b = Integer.parseInt(nums.pop());
				int a = Integer.parseInt(nums.pop());
				int op = ops.indexOf(s);
				if (op == 0) {
					nums.push(String.valueOf(a + b));
				} else if (op == 1) {
					nums.push(String.valueOf(a - b));
				} else if (op == 2) {
					nums.push(String.valueOf(a / b));
				} else if (op == 3) {
					nums.push(String.valueOf(a * b));
				}
				
			} int b = Integer.parseInt(nums.pop()); b Integer.parseInt(nums.pop()) Integer.parseInt Integer nums.pop() nums.pop nums int a = Integer.parseInt(nums.pop()); a Integer.parseInt(nums.pop()) Integer.parseInt Integer nums.pop() nums.pop nums int op = ops.indexOf(s); op ops.indexOf(s) ops.indexOf ops s if (op == 0) {
					nums.push(String.valueOf(a + b));
				} else if (op == 1) {
					nums.push(String.valueOf(a - b));
				} else if (op == 2) {
					nums.push(String.valueOf(a / b));
				} else if (op == 3) {
					nums.push(String.valueOf(a * b));
				} op == 0 op 0 {
					nums.push(String.valueOf(a + b));
				} nums.push(String.valueOf(a + b)) nums.push nums String.valueOf(a + b) String.valueOf String a + b a b if (op == 1) {
					nums.push(String.valueOf(a - b));
				} else if (op == 2) {
					nums.push(String.valueOf(a / b));
				} else if (op == 3) {
					nums.push(String.valueOf(a * b));
				} op == 1 op 1 {
					nums.push(String.valueOf(a - b));
				} nums.push(String.valueOf(a - b)) nums.push nums String.valueOf(a - b) String.valueOf String a - b a b if (op == 2) {
					nums.push(String.valueOf(a / b));
				} else if (op == 3) {
					nums.push(String.valueOf(a * b));
				} op == 2 op 2 {
					nums.push(String.valueOf(a / b));
				} nums.push(String.valueOf(a / b)) nums.push nums String.valueOf(a / b) String.valueOf String a / b a b if (op == 3) {
					nums.push(String.valueOf(a * b));
				} op == 3 op 3 {
					nums.push(String.valueOf(a * b));
				} nums.push(String.valueOf(a * b)) nums.push nums String.valueOf(a * b) String.valueOf String a * b a b output = Integer.parseInt(nums.pop()) output Integer.parseInt(nums.pop()) Integer.parseInt Integer nums.pop() nums.pop nums return output; output ArrayList<String> in in public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		ArrayList<String> input = new ArrayList<>();
		
		while (in.hasNext()) {
			input.add(in.next().trim());
		}
		System.out.println(RPN(input));
		
		in.close();
	} main {
		Scanner in = new Scanner(System.in);
		ArrayList<String> input = new ArrayList<>();
		
		while (in.hasNext()) {
			input.add(in.next().trim());
		}
		System.out.println(RPN(input));
		
		in.close();
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) ArrayList<String> input = new ArrayList<>(); input new ArrayList<>() while (in.hasNext()) {
			input.add(in.next().trim());
		} in.hasNext() in.hasNext in {
			input.add(in.next().trim());
		} input.add(in.next().trim()) input.add input in.next().trim() in.next().trim in.next() in.next in System.out.println(RPN(input)) System.out.println System.out System System.out RPN(input) RPN input in.close() in.close in String[] args args public class Main {
	
	public static int RPN(ArrayList<String> in) {
		int output = 0;
		String ops = "+-/*";
		Stack<String> nums = new Stack<>();
		
		for (String s : in) {
			if (!ops.contains(s)) {
				nums.push(s);
			} else {
				int b = Integer.parseInt(nums.pop());
				int a = Integer.parseInt(nums.pop());
				int op = ops.indexOf(s);
				if (op == 0) {
					nums.push(String.valueOf(a + b));
				} else if (op == 1) {
					nums.push(String.valueOf(a - b));
				} else if (op == 2) {
					nums.push(String.valueOf(a / b));
				} else if (op == 3) {
					nums.push(String.valueOf(a * b));
				}
				
			}
		}
		output = Integer.parseInt(nums.pop());
		
		return output;
	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		ArrayList<String> input = new ArrayList<>();
		
		while (in.hasNext()) {
			input.add(in.next().trim());
		}
		System.out.println(RPN(input));
		
		in.close();
	}
} public class Main {
	
	public static int RPN(ArrayList<String> in) {
		int output = 0;
		String ops = "+-/*";
		Stack<String> nums = new Stack<>();
		
		for (String s : in) {
			if (!ops.contains(s)) {
				nums.push(s);
			} else {
				int b = Integer.parseInt(nums.pop());
				int a = Integer.parseInt(nums.pop());
				int op = ops.indexOf(s);
				if (op == 0) {
					nums.push(String.valueOf(a + b));
				} else if (op == 1) {
					nums.push(String.valueOf(a - b));
				} else if (op == 2) {
					nums.push(String.valueOf(a / b));
				} else if (op == 3) {
					nums.push(String.valueOf(a * b));
				}
				
			}
		}
		output = Integer.parseInt(nums.pop());
		
		return output;
	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		ArrayList<String> input = new ArrayList<>();
		
		while (in.hasNext()) {
			input.add(in.next().trim());
		}
		System.out.println(RPN(input));
		
		in.close();
	}
} Main
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;

public class Main {
	
	public static int RPN(ArrayList<String> in) {
		int output = 0;
		String ops = "+-/*";
		Stack<String> nums = new Stack<>();
		
		for (String s : in) {
			if (!ops.contains(s)) {
				nums.push(s);
			} else {
				int b = Integer.parseInt(nums.pop());
				int a = Integer.parseInt(nums.pop());
				int op = ops.indexOf(s);
				if (op == 0) {
					nums.push(String.valueOf(a + b));
				} else if (op == 1) {
					nums.push(String.valueOf(a - b));
				} else if (op == 2) {
					nums.push(String.valueOf(a / b));
				} else if (op == 3) {
					nums.push(String.valueOf(a * b));
				}
				
			}
		}
		output = Integer.parseInt(nums.pop());
		
		return output;
	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		ArrayList<String> input = new ArrayList<>();
		
		while (in.hasNext()) {
			input.add(in.next().trim());
		}
		System.out.println(RPN(input));
		
		in.close();
	}
}

