import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Stack<String> seq = new Stack<String>();
		String opers = "+-/*";
		ArrayList<String> arr = new ArrayList<String>();
		Scanner out = new Scanner(System.in);
		String line = out.nextLine();
		Scanner in = new Scanner(line);
		while(in.hasNext()) {
			arr.add(in.next());
		}
		for(int i = 0; i < arr.size(); i++) {
			if(!opers.contains(arr.get(i))) seq.push(arr.get(i));
			else {
				int num = Integer.valueOf(seq.pop());
				int num1 = Integer.valueOf(seq.pop());
				if(arr.get(i).equals(opers.substring(0, 1))) {
					seq.push(String.valueOf(num1 + num));
				}
				else if(arr.get(i).equals(opers.substring(1, 2))) {
					seq.push(String.valueOf(num1 - num));
				}
				else if(arr.get(i).equals(opers.substring(2, 3))) {
					seq.push(String.valueOf(num1 / num));
				}
				else {
					seq.push(String.valueOf(num1 * num));
				}
			}
		}
		System.out.println(Integer.valueOf(seq.pop()));
	}

} import java.util.*; util.* java public class Main {
	
	public static void main(String[] args) {
		Stack<String> seq = new Stack<String>();
		String opers = "+-/*";
		ArrayList<String> arr = new ArrayList<String>();
		Scanner out = new Scanner(System.in);
		String line = out.nextLine();
		Scanner in = new Scanner(line);
		while(in.hasNext()) {
			arr.add(in.next());
		}
		for(int i = 0; i < arr.size(); i++) {
			if(!opers.contains(arr.get(i))) seq.push(arr.get(i));
			else {
				int num = Integer.valueOf(seq.pop());
				int num1 = Integer.valueOf(seq.pop());
				if(arr.get(i).equals(opers.substring(0, 1))) {
					seq.push(String.valueOf(num1 + num));
				}
				else if(arr.get(i).equals(opers.substring(1, 2))) {
					seq.push(String.valueOf(num1 - num));
				}
				else if(arr.get(i).equals(opers.substring(2, 3))) {
					seq.push(String.valueOf(num1 / num));
				}
				else {
					seq.push(String.valueOf(num1 * num));
				}
			}
		}
		System.out.println(Integer.valueOf(seq.pop()));
	}

} Main public static void main(String[] args) {
		Stack<String> seq = new Stack<String>();
		String opers = "+-/*";
		ArrayList<String> arr = new ArrayList<String>();
		Scanner out = new Scanner(System.in);
		String line = out.nextLine();
		Scanner in = new Scanner(line);
		while(in.hasNext()) {
			arr.add(in.next());
		}
		for(int i = 0; i < arr.size(); i++) {
			if(!opers.contains(arr.get(i))) seq.push(arr.get(i));
			else {
				int num = Integer.valueOf(seq.pop());
				int num1 = Integer.valueOf(seq.pop());
				if(arr.get(i).equals(opers.substring(0, 1))) {
					seq.push(String.valueOf(num1 + num));
				}
				else if(arr.get(i).equals(opers.substring(1, 2))) {
					seq.push(String.valueOf(num1 - num));
				}
				else if(arr.get(i).equals(opers.substring(2, 3))) {
					seq.push(String.valueOf(num1 / num));
				}
				else {
					seq.push(String.valueOf(num1 * num));
				}
			}
		}
		System.out.println(Integer.valueOf(seq.pop()));
	} main {
		Stack<String> seq = new Stack<String>();
		String opers = "+-/*";
		ArrayList<String> arr = new ArrayList<String>();
		Scanner out = new Scanner(System.in);
		String line = out.nextLine();
		Scanner in = new Scanner(line);
		while(in.hasNext()) {
			arr.add(in.next());
		}
		for(int i = 0; i < arr.size(); i++) {
			if(!opers.contains(arr.get(i))) seq.push(arr.get(i));
			else {
				int num = Integer.valueOf(seq.pop());
				int num1 = Integer.valueOf(seq.pop());
				if(arr.get(i).equals(opers.substring(0, 1))) {
					seq.push(String.valueOf(num1 + num));
				}
				else if(arr.get(i).equals(opers.substring(1, 2))) {
					seq.push(String.valueOf(num1 - num));
				}
				else if(arr.get(i).equals(opers.substring(2, 3))) {
					seq.push(String.valueOf(num1 / num));
				}
				else {
					seq.push(String.valueOf(num1 * num));
				}
			}
		}
		System.out.println(Integer.valueOf(seq.pop()));
	} Stack<String> seq = new Stack<String>(); seq new Stack<String>() String opers = "+-/*"; opers "+-/*" ArrayList<String> arr = new ArrayList<String>(); arr new ArrayList<String>() Scanner out = new Scanner(System.in); out new Scanner(System.in) String line = out.nextLine(); line out.nextLine() out.nextLine out Scanner in = new Scanner(line); in new Scanner(line) while(in.hasNext()) {
			arr.add(in.next());
		} in.hasNext() in.hasNext in {
			arr.add(in.next());
		} arr.add(in.next()) arr.add arr in.next() in.next in for(int i = 0; i < arr.size(); i++) {
			if(!opers.contains(arr.get(i))) seq.push(arr.get(i));
			else {
				int num = Integer.valueOf(seq.pop());
				int num1 = Integer.valueOf(seq.pop());
				if(arr.get(i).equals(opers.substring(0, 1))) {
					seq.push(String.valueOf(num1 + num));
				}
				else if(arr.get(i).equals(opers.substring(1, 2))) {
					seq.push(String.valueOf(num1 - num));
				}
				else if(arr.get(i).equals(opers.substring(2, 3))) {
					seq.push(String.valueOf(num1 / num));
				}
				else {
					seq.push(String.valueOf(num1 * num));
				}
			}
		} int i = 0; int i = 0; i 0 i < arr.size() i arr.size() arr.size arr i++ i++ i {
			if(!opers.contains(arr.get(i))) seq.push(arr.get(i));
			else {
				int num = Integer.valueOf(seq.pop());
				int num1 = Integer.valueOf(seq.pop());
				if(arr.get(i).equals(opers.substring(0, 1))) {
					seq.push(String.valueOf(num1 + num));
				}
				else if(arr.get(i).equals(opers.substring(1, 2))) {
					seq.push(String.valueOf(num1 - num));
				}
				else if(arr.get(i).equals(opers.substring(2, 3))) {
					seq.push(String.valueOf(num1 / num));
				}
				else {
					seq.push(String.valueOf(num1 * num));
				}
			}
		} {
			if(!opers.contains(arr.get(i))) seq.push(arr.get(i));
			else {
				int num = Integer.valueOf(seq.pop());
				int num1 = Integer.valueOf(seq.pop());
				if(arr.get(i).equals(opers.substring(0, 1))) {
					seq.push(String.valueOf(num1 + num));
				}
				else if(arr.get(i).equals(opers.substring(1, 2))) {
					seq.push(String.valueOf(num1 - num));
				}
				else if(arr.get(i).equals(opers.substring(2, 3))) {
					seq.push(String.valueOf(num1 / num));
				}
				else {
					seq.push(String.valueOf(num1 * num));
				}
			}
		} if(!opers.contains(arr.get(i))) seq.push(arr.get(i));
			else {
				int num = Integer.valueOf(seq.pop());
				int num1 = Integer.valueOf(seq.pop());
				if(arr.get(i).equals(opers.substring(0, 1))) {
					seq.push(String.valueOf(num1 + num));
				}
				else if(arr.get(i).equals(opers.substring(1, 2))) {
					seq.push(String.valueOf(num1 - num));
				}
				else if(arr.get(i).equals(opers.substring(2, 3))) {
					seq.push(String.valueOf(num1 / num));
				}
				else {
					seq.push(String.valueOf(num1 * num));
				}
			} !opers.contains(arr.get(i)) opers.contains(arr.get(i)) opers.contains opers arr.get(i) arr.get arr i seq.push(arr.get(i)) seq.push seq arr.get(i) arr.get arr i {
				int num = Integer.valueOf(seq.pop());
				int num1 = Integer.valueOf(seq.pop());
				if(arr.get(i).equals(opers.substring(0, 1))) {
					seq.push(String.valueOf(num1 + num));
				}
				else if(arr.get(i).equals(opers.substring(1, 2))) {
					seq.push(String.valueOf(num1 - num));
				}
				else if(arr.get(i).equals(opers.substring(2, 3))) {
					seq.push(String.valueOf(num1 / num));
				}
				else {
					seq.push(String.valueOf(num1 * num));
				}
			} int num = Integer.valueOf(seq.pop()); num Integer.valueOf(seq.pop()) Integer.valueOf Integer seq.pop() seq.pop seq int num1 = Integer.valueOf(seq.pop()); num1 Integer.valueOf(seq.pop()) Integer.valueOf Integer seq.pop() seq.pop seq if(arr.get(i).equals(opers.substring(0, 1))) {
					seq.push(String.valueOf(num1 + num));
				}
				else if(arr.get(i).equals(opers.substring(1, 2))) {
					seq.push(String.valueOf(num1 - num));
				}
				else if(arr.get(i).equals(opers.substring(2, 3))) {
					seq.push(String.valueOf(num1 / num));
				}
				else {
					seq.push(String.valueOf(num1 * num));
				} arr.get(i).equals(opers.substring(0, 1)) arr.get(i).equals arr.get(i) arr.get arr i opers.substring(0, 1) opers.substring opers 0 1 {
					seq.push(String.valueOf(num1 + num));
				} seq.push(String.valueOf(num1 + num)) seq.push seq String.valueOf(num1 + num) String.valueOf String num1 + num num1 num if(arr.get(i).equals(opers.substring(1, 2))) {
					seq.push(String.valueOf(num1 - num));
				}
				else if(arr.get(i).equals(opers.substring(2, 3))) {
					seq.push(String.valueOf(num1 / num));
				}
				else {
					seq.push(String.valueOf(num1 * num));
				} arr.get(i).equals(opers.substring(1, 2)) arr.get(i).equals arr.get(i) arr.get arr i opers.substring(1, 2) opers.substring opers 1 2 {
					seq.push(String.valueOf(num1 - num));
				} seq.push(String.valueOf(num1 - num)) seq.push seq String.valueOf(num1 - num) String.valueOf String num1 - num num1 num if(arr.get(i).equals(opers.substring(2, 3))) {
					seq.push(String.valueOf(num1 / num));
				}
				else {
					seq.push(String.valueOf(num1 * num));
				} arr.get(i).equals(opers.substring(2, 3)) arr.get(i).equals arr.get(i) arr.get arr i opers.substring(2, 3) opers.substring opers 2 3 {
					seq.push(String.valueOf(num1 / num));
				} seq.push(String.valueOf(num1 / num)) seq.push seq String.valueOf(num1 / num) String.valueOf String num1 / num num1 num {
					seq.push(String.valueOf(num1 * num));
				} seq.push(String.valueOf(num1 * num)) seq.push seq String.valueOf(num1 * num) String.valueOf String num1 * num num1 num System.out.println(Integer.valueOf(seq.pop())) System.out.println System.out System System.out Integer.valueOf(seq.pop()) Integer.valueOf Integer seq.pop() seq.pop seq String[] args args public class Main {
	
	public static void main(String[] args) {
		Stack<String> seq = new Stack<String>();
		String opers = "+-/*";
		ArrayList<String> arr = new ArrayList<String>();
		Scanner out = new Scanner(System.in);
		String line = out.nextLine();
		Scanner in = new Scanner(line);
		while(in.hasNext()) {
			arr.add(in.next());
		}
		for(int i = 0; i < arr.size(); i++) {
			if(!opers.contains(arr.get(i))) seq.push(arr.get(i));
			else {
				int num = Integer.valueOf(seq.pop());
				int num1 = Integer.valueOf(seq.pop());
				if(arr.get(i).equals(opers.substring(0, 1))) {
					seq.push(String.valueOf(num1 + num));
				}
				else if(arr.get(i).equals(opers.substring(1, 2))) {
					seq.push(String.valueOf(num1 - num));
				}
				else if(arr.get(i).equals(opers.substring(2, 3))) {
					seq.push(String.valueOf(num1 / num));
				}
				else {
					seq.push(String.valueOf(num1 * num));
				}
			}
		}
		System.out.println(Integer.valueOf(seq.pop()));
	}

} public class Main {
	
	public static void main(String[] args) {
		Stack<String> seq = new Stack<String>();
		String opers = "+-/*";
		ArrayList<String> arr = new ArrayList<String>();
		Scanner out = new Scanner(System.in);
		String line = out.nextLine();
		Scanner in = new Scanner(line);
		while(in.hasNext()) {
			arr.add(in.next());
		}
		for(int i = 0; i < arr.size(); i++) {
			if(!opers.contains(arr.get(i))) seq.push(arr.get(i));
			else {
				int num = Integer.valueOf(seq.pop());
				int num1 = Integer.valueOf(seq.pop());
				if(arr.get(i).equals(opers.substring(0, 1))) {
					seq.push(String.valueOf(num1 + num));
				}
				else if(arr.get(i).equals(opers.substring(1, 2))) {
					seq.push(String.valueOf(num1 - num));
				}
				else if(arr.get(i).equals(opers.substring(2, 3))) {
					seq.push(String.valueOf(num1 / num));
				}
				else {
					seq.push(String.valueOf(num1 * num));
				}
			}
		}
		System.out.println(Integer.valueOf(seq.pop()));
	}

} Main
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Stack<String> seq = new Stack<String>();
		String opers = "+-/*";
		ArrayList<String> arr = new ArrayList<String>();
		Scanner out = new Scanner(System.in);
		String line = out.nextLine();
		Scanner in = new Scanner(line);
		while(in.hasNext()) {
			arr.add(in.next());
		}
		for(int i = 0; i < arr.size(); i++) {
			if(!opers.contains(arr.get(i))) seq.push(arr.get(i));
			else {
				int num = Integer.valueOf(seq.pop());
				int num1 = Integer.valueOf(seq.pop());
				if(arr.get(i).equals(opers.substring(0, 1))) {
					seq.push(String.valueOf(num1 + num));
				}
				else if(arr.get(i).equals(opers.substring(1, 2))) {
					seq.push(String.valueOf(num1 - num));
				}
				else if(arr.get(i).equals(opers.substring(2, 3))) {
					seq.push(String.valueOf(num1 / num));
				}
				else {
					seq.push(String.valueOf(num1 * num));
				}
			}
		}
		System.out.println(Integer.valueOf(seq.pop()));
	}

}
