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

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lineArr = line.split(" ");

		Deque<String> stack = new ArrayDeque<String>();
		for (String s : lineArr) {
			if ("+".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a + b));
			} else if ("-".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(b - a));
			} else if ("*".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a * b));
			} else {
				stack.push(s);
			}
		}
		System.out.println(stack.pop());
	}
} 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) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lineArr = line.split(" ");

		Deque<String> stack = new ArrayDeque<String>();
		for (String s : lineArr) {
			if ("+".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a + b));
			} else if ("-".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(b - a));
			} else if ("*".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a * b));
			} else {
				stack.push(s);
			}
		}
		System.out.println(stack.pop());
	}
} Main public static void main(String[] args) {
		new Main().run();
	} main {
		new Main().run();
	} new Main().run() new Main().run new Main() String[] args args void run() {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lineArr = line.split(" ");

		Deque<String> stack = new ArrayDeque<String>();
		for (String s : lineArr) {
			if ("+".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a + b));
			} else if ("-".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(b - a));
			} else if ("*".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a * b));
			} else {
				stack.push(s);
			}
		}
		System.out.println(stack.pop());
	} run {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lineArr = line.split(" ");

		Deque<String> stack = new ArrayDeque<String>();
		for (String s : lineArr) {
			if ("+".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a + b));
			} else if ("-".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(b - a));
			} else if ("*".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a * b));
			} else {
				stack.push(s);
			}
		}
		System.out.println(stack.pop());
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc String[] lineArr = line.split(" "); lineArr line.split(" ") line.split line " " Deque<String> stack = new ArrayDeque<String>(); stack new ArrayDeque<String>() for (String s : lineArr) {
			if ("+".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a + b));
			} else if ("-".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(b - a));
			} else if ("*".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a * b));
			} else {
				stack.push(s);
			}
		} String s lineArr {
			if ("+".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a + b));
			} else if ("-".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(b - a));
			} else if ("*".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a * b));
			} else {
				stack.push(s);
			}
		} {
			if ("+".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a + b));
			} else if ("-".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(b - a));
			} else if ("*".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a * b));
			} else {
				stack.push(s);
			}
		} if ("+".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a + b));
			} else if ("-".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(b - a));
			} else if ("*".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a * b));
			} else {
				stack.push(s);
			} "+".equals(s) "+".equals "+" s {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a + b));
			} int a = Integer.parseInt(stack.pop()); a Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack int b = Integer.parseInt(stack.pop()); b Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack stack.push(String.valueOf(a + b)) stack.push stack String.valueOf(a + b) String.valueOf String a + b a b if ("-".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(b - a));
			} else if ("*".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a * b));
			} else {
				stack.push(s);
			} "-".equals(s) "-".equals "-" s {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(b - a));
			} int a = Integer.parseInt(stack.pop()); a Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack int b = Integer.parseInt(stack.pop()); b Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack stack.push(String.valueOf(b - a)) stack.push stack String.valueOf(b - a) String.valueOf String b - a b a if ("*".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a * b));
			} else {
				stack.push(s);
			} "*".equals(s) "*".equals "*" s {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a * b));
			} int a = Integer.parseInt(stack.pop()); a Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack int b = Integer.parseInt(stack.pop()); b Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack stack.push(String.valueOf(a * b)) stack.push stack String.valueOf(a * b) String.valueOf String a * b a b {
				stack.push(s);
			} stack.push(s) stack.push stack s System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lineArr = line.split(" ");

		Deque<String> stack = new ArrayDeque<String>();
		for (String s : lineArr) {
			if ("+".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a + b));
			} else if ("-".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(b - a));
			} else if ("*".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a * b));
			} else {
				stack.push(s);
			}
		}
		System.out.println(stack.pop());
	}
} public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lineArr = line.split(" ");

		Deque<String> stack = new ArrayDeque<String>();
		for (String s : lineArr) {
			if ("+".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a + b));
			} else if ("-".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(b - a));
			} else if ("*".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a * b));
			} else {
				stack.push(s);
			}
		}
		System.out.println(stack.pop());
	}
} Main

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

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lineArr = line.split(" ");

		Deque<String> stack = new ArrayDeque<String>();
		for (String s : lineArr) {
			if ("+".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a + b));
			} else if ("-".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(b - a));
			} else if ("*".equals(s)) {
				int a = Integer.parseInt(stack.pop());
				int b = Integer.parseInt(stack.pop());
				stack.push(String.valueOf(a * b));
			} else {
				stack.push(s);
			}
		}
		System.out.println(stack.pop());
	}
}