import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String[] inputs = sc.nextLine().split(" ");
		sc.close();

		Deque<Integer> dq = new ArrayDeque<>();

		for(String val : inputs) {

			if(isInt(val)) {
				int num = Integer.parseInt(val);
				dq.push(num);
			} else {
				calc(dq, val);
			}
		}

		System.out.println(dq.pop());

	}

	private static void calc(Deque<Integer> dq, String val) {

		char ope = val.charAt(0);
		int b = dq.pop();
		int a = dq.pop();

		switch (ope) {
		case '+':
			dq.push(a + b);
			break;
		case '-':
			dq.push(a - b);
			break;
		case '*':
			dq.push(a * b);
			break;
		default:
			break;
		}

	}

	private static boolean isInt(String val) {

		try {
			Integer.parseInt(val);
			return true;
		} catch (NumberFormatException e) {
			return false;
		}
	}

} import java.util.ArrayDeque; ArrayDeque java.util import java.util.Deque; Deque java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String[] inputs = sc.nextLine().split(" ");
		sc.close();

		Deque<Integer> dq = new ArrayDeque<>();

		for(String val : inputs) {

			if(isInt(val)) {
				int num = Integer.parseInt(val);
				dq.push(num);
			} else {
				calc(dq, val);
			}
		}

		System.out.println(dq.pop());

	}

	private static void calc(Deque<Integer> dq, String val) {

		char ope = val.charAt(0);
		int b = dq.pop();
		int a = dq.pop();

		switch (ope) {
		case '+':
			dq.push(a + b);
			break;
		case '-':
			dq.push(a - b);
			break;
		case '*':
			dq.push(a * b);
			break;
		default:
			break;
		}

	}

	private static boolean isInt(String val) {

		try {
			Integer.parseInt(val);
			return true;
		} catch (NumberFormatException e) {
			return false;
		}
	}

} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String[] inputs = sc.nextLine().split(" ");
		sc.close();

		Deque<Integer> dq = new ArrayDeque<>();

		for(String val : inputs) {

			if(isInt(val)) {
				int num = Integer.parseInt(val);
				dq.push(num);
			} else {
				calc(dq, val);
			}
		}

		System.out.println(dq.pop());

	} main {

		Scanner sc = new Scanner(System.in);
		String[] inputs = sc.nextLine().split(" ");
		sc.close();

		Deque<Integer> dq = new ArrayDeque<>();

		for(String val : inputs) {

			if(isInt(val)) {
				int num = Integer.parseInt(val);
				dq.push(num);
			} else {
				calc(dq, val);
			}
		}

		System.out.println(dq.pop());

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] inputs = sc.nextLine().split(" "); inputs sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " sc.close() sc.close sc Deque<Integer> dq = new ArrayDeque<>(); dq new ArrayDeque<>() for(String val : inputs) {

			if(isInt(val)) {
				int num = Integer.parseInt(val);
				dq.push(num);
			} else {
				calc(dq, val);
			}
		} String val inputs {

			if(isInt(val)) {
				int num = Integer.parseInt(val);
				dq.push(num);
			} else {
				calc(dq, val);
			}
		} {

			if(isInt(val)) {
				int num = Integer.parseInt(val);
				dq.push(num);
			} else {
				calc(dq, val);
			}
		} if(isInt(val)) {
				int num = Integer.parseInt(val);
				dq.push(num);
			} else {
				calc(dq, val);
			} isInt(val) isInt val {
				int num = Integer.parseInt(val);
				dq.push(num);
			} int num = Integer.parseInt(val); num Integer.parseInt(val) Integer.parseInt Integer val dq.push(num) dq.push dq num {
				calc(dq, val);
			} calc(dq, val) calc dq val System.out.println(dq.pop()) System.out.println System.out System System.out dq.pop() dq.pop dq String[] args args private static void calc(Deque<Integer> dq, String val) {

		char ope = val.charAt(0);
		int b = dq.pop();
		int a = dq.pop();

		switch (ope) {
		case '+':
			dq.push(a + b);
			break;
		case '-':
			dq.push(a - b);
			break;
		case '*':
			dq.push(a * b);
			break;
		default:
			break;
		}

	} calc {

		char ope = val.charAt(0);
		int b = dq.pop();
		int a = dq.pop();

		switch (ope) {
		case '+':
			dq.push(a + b);
			break;
		case '-':
			dq.push(a - b);
			break;
		case '*':
			dq.push(a * b);
			break;
		default:
			break;
		}

	} char ope = val.charAt(0); ope val.charAt(0) val.charAt val 0 int b = dq.pop(); b dq.pop() dq.pop dq int a = dq.pop(); a dq.pop() dq.pop dq switch (ope) {
		case '+':
			dq.push(a + b);
			break;
		case '-':
			dq.push(a - b);
			break;
		case '*':
			dq.push(a * b);
			break;
		default:
			break;
		} ope case '+': '+' case '+': dq.push(a + b) dq.push dq a + b a b break; case '-': '-' case '-': dq.push(a - b) dq.push dq a - b a b break; case '*': '*' case '*': dq.push(a * b) dq.push dq a * b a b break; default: default: break; Deque<Integer> dq dq String val val private static boolean isInt(String val) {

		try {
			Integer.parseInt(val);
			return true;
		} catch (NumberFormatException e) {
			return false;
		}
	} isInt {

		try {
			Integer.parseInt(val);
			return true;
		} catch (NumberFormatException e) {
			return false;
		}
	} try {
			Integer.parseInt(val);
			return true;
		} catch (NumberFormatException e) {
			return false;
		} catch (NumberFormatException e) {
			return false;
		} NumberFormatException e {
			return false;
		} return false; false {
			Integer.parseInt(val);
			return true;
		} Integer.parseInt(val) Integer.parseInt Integer val return true; true String val val public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String[] inputs = sc.nextLine().split(" ");
		sc.close();

		Deque<Integer> dq = new ArrayDeque<>();

		for(String val : inputs) {

			if(isInt(val)) {
				int num = Integer.parseInt(val);
				dq.push(num);
			} else {
				calc(dq, val);
			}
		}

		System.out.println(dq.pop());

	}

	private static void calc(Deque<Integer> dq, String val) {

		char ope = val.charAt(0);
		int b = dq.pop();
		int a = dq.pop();

		switch (ope) {
		case '+':
			dq.push(a + b);
			break;
		case '-':
			dq.push(a - b);
			break;
		case '*':
			dq.push(a * b);
			break;
		default:
			break;
		}

	}

	private static boolean isInt(String val) {

		try {
			Integer.parseInt(val);
			return true;
		} catch (NumberFormatException e) {
			return false;
		}
	}

} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String[] inputs = sc.nextLine().split(" ");
		sc.close();

		Deque<Integer> dq = new ArrayDeque<>();

		for(String val : inputs) {

			if(isInt(val)) {
				int num = Integer.parseInt(val);
				dq.push(num);
			} else {
				calc(dq, val);
			}
		}

		System.out.println(dq.pop());

	}

	private static void calc(Deque<Integer> dq, String val) {

		char ope = val.charAt(0);
		int b = dq.pop();
		int a = dq.pop();

		switch (ope) {
		case '+':
			dq.push(a + b);
			break;
		case '-':
			dq.push(a - b);
			break;
		case '*':
			dq.push(a * b);
			break;
		default:
			break;
		}

	}

	private static boolean isInt(String val) {

		try {
			Integer.parseInt(val);
			return true;
		} catch (NumberFormatException e) {
			return false;
		}
	}

} Main
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String[] inputs = sc.nextLine().split(" ");
		sc.close();

		Deque<Integer> dq = new ArrayDeque<>();

		for(String val : inputs) {

			if(isInt(val)) {
				int num = Integer.parseInt(val);
				dq.push(num);
			} else {
				calc(dq, val);
			}
		}

		System.out.println(dq.pop());

	}

	private static void calc(Deque<Integer> dq, String val) {

		char ope = val.charAt(0);
		int b = dq.pop();
		int a = dq.pop();

		switch (ope) {
		case '+':
			dq.push(a + b);
			break;
		case '-':
			dq.push(a - b);
			break;
		case '*':
			dq.push(a * b);
			break;
		default:
			break;
		}

	}

	private static boolean isInt(String val) {

		try {
			Integer.parseInt(val);
			return true;
		} catch (NumberFormatException e) {
			return false;
		}
	}

}