import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		StackImpl e = new Main().new StackImpl();
//		while(s.hasNext()) {
			String[] line = s.nextLine().split(" ");
			for(int i=0 ; i<line.length ; i++) {
			if("+".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a+b);
			} else if("-".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a-b);
			} else if("*".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a*b);
			}else {
				e.push(new Integer(line[i]).intValue());
			}
//			}
		}
		System.out.println(e.pop());
	}

	public class StackImpl {

		int[] stack;
		int index;

		public StackImpl() {
			stack = new int[100];
			index = 0;
		}

		public void push(int value) {
			stack[index] = value;
			index++;
		}

		public int pop() {
			index--;
			int returnV = stack[index];
			stack[index] = 0;
			return returnV;
		}
	}
} import java.util.Scanner; Scanner java.util public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		StackImpl e = new Main().new StackImpl();
//		while(s.hasNext()) {
			String[] line = s.nextLine().split(" ");
			for(int i=0 ; i<line.length ; i++) {
			if("+".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a+b);
			} else if("-".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a-b);
			} else if("*".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a*b);
			}else {
				e.push(new Integer(line[i]).intValue());
			}
//			}
		}
		System.out.println(e.pop());
	}

	public class StackImpl {

		int[] stack;
		int index;

		public StackImpl() {
			stack = new int[100];
			index = 0;
		}

		public void push(int value) {
			stack[index] = value;
			index++;
		}

		public int pop() {
			index--;
			int returnV = stack[index];
			stack[index] = 0;
			return returnV;
		}
	}
} Main public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		StackImpl e = new Main().new StackImpl();
//		while(s.hasNext()) {
			String[] line = s.nextLine().split(" ");
			for(int i=0 ; i<line.length ; i++) {
			if("+".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a+b);
			} else if("-".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a-b);
			} else if("*".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a*b);
			}else {
				e.push(new Integer(line[i]).intValue());
			}
//			}
		}
		System.out.println(e.pop());
	} main {
		Scanner s = new Scanner(System.in);
		StackImpl e = new Main().new StackImpl();
//		while(s.hasNext()) {
			String[] line = s.nextLine().split(" ");
			for(int i=0 ; i<line.length ; i++) {
			if("+".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a+b);
			} else if("-".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a-b);
			} else if("*".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a*b);
			}else {
				e.push(new Integer(line[i]).intValue());
			}
//			}
		}
		System.out.println(e.pop());
	} Scanner s = new Scanner(System.in); s new Scanner(System.in) StackImpl e = new Main().new StackImpl(); e new Main().new StackImpl() new Main() new Main() String[] line = s.nextLine().split(" "); line s.nextLine().split(" ") s.nextLine().split s.nextLine() s.nextLine s " " for(int i=0 ; i<line.length ; i++) {
			if("+".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a+b);
			} else if("-".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a-b);
			} else if("*".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a*b);
			}else {
				e.push(new Integer(line[i]).intValue());
			}
//			}
		} int i=0 ; int i=0 ; i 0 i<line.length i line.length line line.length i++ i++ i {
			if("+".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a+b);
			} else if("-".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a-b);
			} else if("*".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a*b);
			}else {
				e.push(new Integer(line[i]).intValue());
			}
//			}
		} {
			if("+".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a+b);
			} else if("-".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a-b);
			} else if("*".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a*b);
			}else {
				e.push(new Integer(line[i]).intValue());
			}
//			}
		} if("+".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a+b);
			} else if("-".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a-b);
			} else if("*".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a*b);
			}else {
				e.push(new Integer(line[i]).intValue());
			} "+".equals(line[i]) "+".equals "+" line[i] line i {
				int b = e.pop();
				int a = e.pop();
				e.push(a+b);
			} int b = e.pop(); b e.pop() e.pop e int a = e.pop(); a e.pop() e.pop e e.push(a+b) e.push e a+b a b if("-".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a-b);
			} else if("*".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a*b);
			}else {
				e.push(new Integer(line[i]).intValue());
			} "-".equals(line[i]) "-".equals "-" line[i] line i {
				int b = e.pop();
				int a = e.pop();
				e.push(a-b);
			} int b = e.pop(); b e.pop() e.pop e int a = e.pop(); a e.pop() e.pop e e.push(a-b) e.push e a-b a b if("*".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a*b);
			}else {
				e.push(new Integer(line[i]).intValue());
			} "*".equals(line[i]) "*".equals "*" line[i] line i {
				int b = e.pop();
				int a = e.pop();
				e.push(a*b);
			} int b = e.pop(); b e.pop() e.pop e int a = e.pop(); a e.pop() e.pop e e.push(a*b) e.push e a*b a b {
				e.push(new Integer(line[i]).intValue());
			} e.push(new Integer(line[i]).intValue()) e.push e new Integer(line[i]).intValue() new Integer(line[i]).intValue new Integer(line[i]) System.out.println(e.pop()) System.out.println System.out System System.out e.pop() e.pop e String[] args args public class StackImpl {

		int[] stack;
		int index;

		public StackImpl() {
			stack = new int[100];
			index = 0;
		}

		public void push(int value) {
			stack[index] = value;
			index++;
		}

		public int pop() {
			index--;
			int returnV = stack[index];
			stack[index] = 0;
			return returnV;
		}
	} StackImpl int[] stack; stack int index; index public StackImpl() {
			stack = new int[100];
			index = 0;
		} StackImpl {
			stack = new int[100];
			index = 0;
		} stack = new int[100] stack new int[100] 100 index = 0 index 0 public void push(int value) {
			stack[index] = value;
			index++;
		} push {
			stack[index] = value;
			index++;
		} stack[index] = value stack[index] stack index value index++ index int value value public int pop() {
			index--;
			int returnV = stack[index];
			stack[index] = 0;
			return returnV;
		} pop {
			index--;
			int returnV = stack[index];
			stack[index] = 0;
			return returnV;
		} index-- index int returnV = stack[index]; returnV stack[index] stack index stack[index] = 0 stack[index] stack index 0 return returnV; returnV public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		StackImpl e = new Main().new StackImpl();
//		while(s.hasNext()) {
			String[] line = s.nextLine().split(" ");
			for(int i=0 ; i<line.length ; i++) {
			if("+".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a+b);
			} else if("-".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a-b);
			} else if("*".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a*b);
			}else {
				e.push(new Integer(line[i]).intValue());
			}
//			}
		}
		System.out.println(e.pop());
	}

	public class StackImpl {

		int[] stack;
		int index;

		public StackImpl() {
			stack = new int[100];
			index = 0;
		}

		public void push(int value) {
			stack[index] = value;
			index++;
		}

		public int pop() {
			index--;
			int returnV = stack[index];
			stack[index] = 0;
			return returnV;
		}
	}
} public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		StackImpl e = new Main().new StackImpl();
//		while(s.hasNext()) {
			String[] line = s.nextLine().split(" ");
			for(int i=0 ; i<line.length ; i++) {
			if("+".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a+b);
			} else if("-".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a-b);
			} else if("*".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a*b);
			}else {
				e.push(new Integer(line[i]).intValue());
			}
//			}
		}
		System.out.println(e.pop());
	}

	public class StackImpl {

		int[] stack;
		int index;

		public StackImpl() {
			stack = new int[100];
			index = 0;
		}

		public void push(int value) {
			stack[index] = value;
			index++;
		}

		public int pop() {
			index--;
			int returnV = stack[index];
			stack[index] = 0;
			return returnV;
		}
	}
} Main
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		StackImpl e = new Main().new StackImpl();
//		while(s.hasNext()) {
			String[] line = s.nextLine().split(" ");
			for(int i=0 ; i<line.length ; i++) {
			if("+".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a+b);
			} else if("-".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a-b);
			} else if("*".equals(line[i])) {
				int b = e.pop();
				int a = e.pop();
				e.push(a*b);
			}else {
				e.push(new Integer(line[i]).intValue());
			}
//			}
		}
		System.out.println(e.pop());
	}

	public class StackImpl {

		int[] stack;
		int index;

		public StackImpl() {
			stack = new int[100];
			index = 0;
		}

		public void push(int value) {
			stack[index] = value;
			index++;
		}

		public int pop() {
			index--;
			int returnV = stack[index];
			stack[index] = 0;
			return returnV;
		}
	}
}