import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StackSub createDataArr = new StackSub(in.readLine().split(" "));
		System.out.println(createDataArr.calcData());
	}
}

class StackSub {
	private String[] readData;
	private int[] stack = new int[100];
	private int ans;

	StackSub(String[] readData) {
		this.readData = readData;
	}

	void createData(String[] criateDataArr) {
		readData = new String[criateDataArr.length];
	}

	int calcData() {
		int stackNum = 0;
		for (int i = 0; i < readData.length; i++) {
			if (readData[i].charAt(0) == '+') {
				stack[stackNum - 2] = stack[stackNum - 2] + stack[stackNum - 1];
				stackNum -= 1;
			} else if (readData[i].charAt(0) == '-') {
				stack[stackNum - 2] = stack[stackNum - 2] - stack[stackNum - 1];
				stackNum -= 1;
			} else if (readData[i].charAt(0) == '*') {
				stack[stackNum - 2] = stack[stackNum - 2] * stack[stackNum - 1];
				stackNum -= 1;
			} else {
				stack[stackNum] = Integer.parseInt(readData[i]);
				stackNum++;
			}
		}
		ans = stack[0];
		return ans;
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StackSub createDataArr = new StackSub(in.readLine().split(" "));
		System.out.println(createDataArr.calcData());
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StackSub createDataArr = new StackSub(in.readLine().split(" "));
		System.out.println(createDataArr.calcData());
	} main {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StackSub createDataArr = new StackSub(in.readLine().split(" "));
		System.out.println(createDataArr.calcData());
	} BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) StackSub createDataArr = new StackSub(in.readLine().split(" ")); createDataArr new StackSub(in.readLine().split(" ")) System.out.println(createDataArr.calcData()) System.out.println System.out System System.out createDataArr.calcData() createDataArr.calcData createDataArr String[] args args class StackSub {
	private String[] readData;
	private int[] stack = new int[100];
	private int ans;

	StackSub(String[] readData) {
		this.readData = readData;
	}

	void createData(String[] criateDataArr) {
		readData = new String[criateDataArr.length];
	}

	int calcData() {
		int stackNum = 0;
		for (int i = 0; i < readData.length; i++) {
			if (readData[i].charAt(0) == '+') {
				stack[stackNum - 2] = stack[stackNum - 2] + stack[stackNum - 1];
				stackNum -= 1;
			} else if (readData[i].charAt(0) == '-') {
				stack[stackNum - 2] = stack[stackNum - 2] - stack[stackNum - 1];
				stackNum -= 1;
			} else if (readData[i].charAt(0) == '*') {
				stack[stackNum - 2] = stack[stackNum - 2] * stack[stackNum - 1];
				stackNum -= 1;
			} else {
				stack[stackNum] = Integer.parseInt(readData[i]);
				stackNum++;
			}
		}
		ans = stack[0];
		return ans;
	}
} StackSub private String[] readData; readData private int[] stack = new int[100]; stack new int[100] 100 private int ans; ans StackSub(String[] readData) {
		this.readData = readData;
	} StackSub {
		this.readData = readData;
	} this.readData = readData this.readData this this.readData readData String[] readData readData void createData(String[] criateDataArr) {
		readData = new String[criateDataArr.length];
	} createData {
		readData = new String[criateDataArr.length];
	} readData = new String[criateDataArr.length] readData new String[criateDataArr.length] criateDataArr.length criateDataArr criateDataArr.length String[] criateDataArr criateDataArr int calcData() {
		int stackNum = 0;
		for (int i = 0; i < readData.length; i++) {
			if (readData[i].charAt(0) == '+') {
				stack[stackNum - 2] = stack[stackNum - 2] + stack[stackNum - 1];
				stackNum -= 1;
			} else if (readData[i].charAt(0) == '-') {
				stack[stackNum - 2] = stack[stackNum - 2] - stack[stackNum - 1];
				stackNum -= 1;
			} else if (readData[i].charAt(0) == '*') {
				stack[stackNum - 2] = stack[stackNum - 2] * stack[stackNum - 1];
				stackNum -= 1;
			} else {
				stack[stackNum] = Integer.parseInt(readData[i]);
				stackNum++;
			}
		}
		ans = stack[0];
		return ans;
	} calcData {
		int stackNum = 0;
		for (int i = 0; i < readData.length; i++) {
			if (readData[i].charAt(0) == '+') {
				stack[stackNum - 2] = stack[stackNum - 2] + stack[stackNum - 1];
				stackNum -= 1;
			} else if (readData[i].charAt(0) == '-') {
				stack[stackNum - 2] = stack[stackNum - 2] - stack[stackNum - 1];
				stackNum -= 1;
			} else if (readData[i].charAt(0) == '*') {
				stack[stackNum - 2] = stack[stackNum - 2] * stack[stackNum - 1];
				stackNum -= 1;
			} else {
				stack[stackNum] = Integer.parseInt(readData[i]);
				stackNum++;
			}
		}
		ans = stack[0];
		return ans;
	} int stackNum = 0; stackNum 0 for (int i = 0; i < readData.length; i++) {
			if (readData[i].charAt(0) == '+') {
				stack[stackNum - 2] = stack[stackNum - 2] + stack[stackNum - 1];
				stackNum -= 1;
			} else if (readData[i].charAt(0) == '-') {
				stack[stackNum - 2] = stack[stackNum - 2] - stack[stackNum - 1];
				stackNum -= 1;
			} else if (readData[i].charAt(0) == '*') {
				stack[stackNum - 2] = stack[stackNum - 2] * stack[stackNum - 1];
				stackNum -= 1;
			} else {
				stack[stackNum] = Integer.parseInt(readData[i]);
				stackNum++;
			}
		} int i = 0; int i = 0; i 0 i < readData.length i readData.length readData readData.length i++ i++ i {
			if (readData[i].charAt(0) == '+') {
				stack[stackNum - 2] = stack[stackNum - 2] + stack[stackNum - 1];
				stackNum -= 1;
			} else if (readData[i].charAt(0) == '-') {
				stack[stackNum - 2] = stack[stackNum - 2] - stack[stackNum - 1];
				stackNum -= 1;
			} else if (readData[i].charAt(0) == '*') {
				stack[stackNum - 2] = stack[stackNum - 2] * stack[stackNum - 1];
				stackNum -= 1;
			} else {
				stack[stackNum] = Integer.parseInt(readData[i]);
				stackNum++;
			}
		} {
			if (readData[i].charAt(0) == '+') {
				stack[stackNum - 2] = stack[stackNum - 2] + stack[stackNum - 1];
				stackNum -= 1;
			} else if (readData[i].charAt(0) == '-') {
				stack[stackNum - 2] = stack[stackNum - 2] - stack[stackNum - 1];
				stackNum -= 1;
			} else if (readData[i].charAt(0) == '*') {
				stack[stackNum - 2] = stack[stackNum - 2] * stack[stackNum - 1];
				stackNum -= 1;
			} else {
				stack[stackNum] = Integer.parseInt(readData[i]);
				stackNum++;
			}
		} if (readData[i].charAt(0) == '+') {
				stack[stackNum - 2] = stack[stackNum - 2] + stack[stackNum - 1];
				stackNum -= 1;
			} else if (readData[i].charAt(0) == '-') {
				stack[stackNum - 2] = stack[stackNum - 2] - stack[stackNum - 1];
				stackNum -= 1;
			} else if (readData[i].charAt(0) == '*') {
				stack[stackNum - 2] = stack[stackNum - 2] * stack[stackNum - 1];
				stackNum -= 1;
			} else {
				stack[stackNum] = Integer.parseInt(readData[i]);
				stackNum++;
			} readData[i].charAt(0) == '+' readData[i].charAt(0) readData[i].charAt readData[i] readData i 0 '+' {
				stack[stackNum - 2] = stack[stackNum - 2] + stack[stackNum - 1];
				stackNum -= 1;
			} stack[stackNum - 2] = stack[stackNum - 2] + stack[stackNum - 1] stack[stackNum - 2] stack stackNum - 2 stackNum 2 stack[stackNum - 2] + stack[stackNum - 1] stack[stackNum - 2] stack stackNum - 2 stackNum 2 stack[stackNum - 1] stack stackNum - 1 stackNum 1 stackNum -= 1 stackNum 1 if (readData[i].charAt(0) == '-') {
				stack[stackNum - 2] = stack[stackNum - 2] - stack[stackNum - 1];
				stackNum -= 1;
			} else if (readData[i].charAt(0) == '*') {
				stack[stackNum - 2] = stack[stackNum - 2] * stack[stackNum - 1];
				stackNum -= 1;
			} else {
				stack[stackNum] = Integer.parseInt(readData[i]);
				stackNum++;
			} readData[i].charAt(0) == '-' readData[i].charAt(0) readData[i].charAt readData[i] readData i 0 '-' {
				stack[stackNum - 2] = stack[stackNum - 2] - stack[stackNum - 1];
				stackNum -= 1;
			} stack[stackNum - 2] = stack[stackNum - 2] - stack[stackNum - 1] stack[stackNum - 2] stack stackNum - 2 stackNum 2 stack[stackNum - 2] - stack[stackNum - 1] stack[stackNum - 2] stack stackNum - 2 stackNum 2 stack[stackNum - 1] stack stackNum - 1 stackNum 1 stackNum -= 1 stackNum 1 if (readData[i].charAt(0) == '*') {
				stack[stackNum - 2] = stack[stackNum - 2] * stack[stackNum - 1];
				stackNum -= 1;
			} else {
				stack[stackNum] = Integer.parseInt(readData[i]);
				stackNum++;
			} readData[i].charAt(0) == '*' readData[i].charAt(0) readData[i].charAt readData[i] readData i 0 '*' {
				stack[stackNum - 2] = stack[stackNum - 2] * stack[stackNum - 1];
				stackNum -= 1;
			} stack[stackNum - 2] = stack[stackNum - 2] * stack[stackNum - 1] stack[stackNum - 2] stack stackNum - 2 stackNum 2 stack[stackNum - 2] * stack[stackNum - 1] stack[stackNum - 2] stack stackNum - 2 stackNum 2 stack[stackNum - 1] stack stackNum - 1 stackNum 1 stackNum -= 1 stackNum 1 {
				stack[stackNum] = Integer.parseInt(readData[i]);
				stackNum++;
			} stack[stackNum] = Integer.parseInt(readData[i]) stack[stackNum] stack stackNum Integer.parseInt(readData[i]) Integer.parseInt Integer readData[i] readData i stackNum++ stackNum ans = stack[0] ans stack[0] stack 0 return ans; ans public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StackSub createDataArr = new StackSub(in.readLine().split(" "));
		System.out.println(createDataArr.calcData());
	}
} public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StackSub createDataArr = new StackSub(in.readLine().split(" "));
		System.out.println(createDataArr.calcData());
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StackSub createDataArr = new StackSub(in.readLine().split(" "));
		System.out.println(createDataArr.calcData());
	}
}

class StackSub {
	private String[] readData;
	private int[] stack = new int[100];
	private int ans;

	StackSub(String[] readData) {
		this.readData = readData;
	}

	void createData(String[] criateDataArr) {
		readData = new String[criateDataArr.length];
	}

	int calcData() {
		int stackNum = 0;
		for (int i = 0; i < readData.length; i++) {
			if (readData[i].charAt(0) == '+') {
				stack[stackNum - 2] = stack[stackNum - 2] + stack[stackNum - 1];
				stackNum -= 1;
			} else if (readData[i].charAt(0) == '-') {
				stack[stackNum - 2] = stack[stackNum - 2] - stack[stackNum - 1];
				stackNum -= 1;
			} else if (readData[i].charAt(0) == '*') {
				stack[stackNum - 2] = stack[stackNum - 2] * stack[stackNum - 1];
				stackNum -= 1;
			} else {
				stack[stackNum] = Integer.parseInt(readData[i]);
				stackNum++;
			}
		}
		ans = stack[0];
		return ans;
	}
}