import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;


class Main {

	public static void main(String[] args) {

		Input stdIn = new Input();
		int x, y;

		List<String> inputline = stdIn.getLineString();
		Deque<Integer> stack = new LinkedList<>();

		for (int i = 0; i < inputline.size(); i++) {
			switch (inputline.get(i)) {
			case "+":
				y = stack.pop();
				x = stack.pop();
				stack.push(x + y);
				break;
			case "-":
				y = stack.pop();
				x = stack.pop();
				stack.push(x - y);
				break;
			case "*":
				y = stack.pop();
				x = stack.pop();
				stack.push(x * y);
				break;
			default:
				stack.push(Integer.parseInt(inputline.get(i)));
			}
		}
		System.out.println(stack.peek());
	}
}
class Input {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	Input() {
		super();
	}

	public Integer getValue() {
		try {
			String[] s = br.readLine().trim().split(" ");
			return Integer.parseInt(s[0]);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	public List<Integer> getLine(int n) {
		List<Integer> values = new ArrayList<>();
		try {
			String[] s = br.readLine().trim().split(" ");
			for(int i = 0; i < n; i++) {
				values.add(Integer.parseInt(s[i]));
			}
			return values;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
	public List<String> getLineString() {
		try {
			String[] s = br.readLine().trim().split(" ");
			List<String> values = Arrays.asList(s);
			return values;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
} import java.util.Deque; Deque java.util import java.util.LinkedList; LinkedList java.util import java.util.List; List java.util import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.List; List java.util class Main {

	public static void main(String[] args) {

		Input stdIn = new Input();
		int x, y;

		List<String> inputline = stdIn.getLineString();
		Deque<Integer> stack = new LinkedList<>();

		for (int i = 0; i < inputline.size(); i++) {
			switch (inputline.get(i)) {
			case "+":
				y = stack.pop();
				x = stack.pop();
				stack.push(x + y);
				break;
			case "-":
				y = stack.pop();
				x = stack.pop();
				stack.push(x - y);
				break;
			case "*":
				y = stack.pop();
				x = stack.pop();
				stack.push(x * y);
				break;
			default:
				stack.push(Integer.parseInt(inputline.get(i)));
			}
		}
		System.out.println(stack.peek());
	}
} Main public static void main(String[] args) {

		Input stdIn = new Input();
		int x, y;

		List<String> inputline = stdIn.getLineString();
		Deque<Integer> stack = new LinkedList<>();

		for (int i = 0; i < inputline.size(); i++) {
			switch (inputline.get(i)) {
			case "+":
				y = stack.pop();
				x = stack.pop();
				stack.push(x + y);
				break;
			case "-":
				y = stack.pop();
				x = stack.pop();
				stack.push(x - y);
				break;
			case "*":
				y = stack.pop();
				x = stack.pop();
				stack.push(x * y);
				break;
			default:
				stack.push(Integer.parseInt(inputline.get(i)));
			}
		}
		System.out.println(stack.peek());
	} main {

		Input stdIn = new Input();
		int x, y;

		List<String> inputline = stdIn.getLineString();
		Deque<Integer> stack = new LinkedList<>();

		for (int i = 0; i < inputline.size(); i++) {
			switch (inputline.get(i)) {
			case "+":
				y = stack.pop();
				x = stack.pop();
				stack.push(x + y);
				break;
			case "-":
				y = stack.pop();
				x = stack.pop();
				stack.push(x - y);
				break;
			case "*":
				y = stack.pop();
				x = stack.pop();
				stack.push(x * y);
				break;
			default:
				stack.push(Integer.parseInt(inputline.get(i)));
			}
		}
		System.out.println(stack.peek());
	} Input stdIn = new Input(); stdIn new Input() int x x y; y List<String> inputline = stdIn.getLineString(); inputline stdIn.getLineString() stdIn.getLineString stdIn Deque<Integer> stack = new LinkedList<>(); stack new LinkedList<>() for (int i = 0; i < inputline.size(); i++) {
			switch (inputline.get(i)) {
			case "+":
				y = stack.pop();
				x = stack.pop();
				stack.push(x + y);
				break;
			case "-":
				y = stack.pop();
				x = stack.pop();
				stack.push(x - y);
				break;
			case "*":
				y = stack.pop();
				x = stack.pop();
				stack.push(x * y);
				break;
			default:
				stack.push(Integer.parseInt(inputline.get(i)));
			}
		} int i = 0; int i = 0; i 0 i < inputline.size() i inputline.size() inputline.size inputline i++ i++ i {
			switch (inputline.get(i)) {
			case "+":
				y = stack.pop();
				x = stack.pop();
				stack.push(x + y);
				break;
			case "-":
				y = stack.pop();
				x = stack.pop();
				stack.push(x - y);
				break;
			case "*":
				y = stack.pop();
				x = stack.pop();
				stack.push(x * y);
				break;
			default:
				stack.push(Integer.parseInt(inputline.get(i)));
			}
		} {
			switch (inputline.get(i)) {
			case "+":
				y = stack.pop();
				x = stack.pop();
				stack.push(x + y);
				break;
			case "-":
				y = stack.pop();
				x = stack.pop();
				stack.push(x - y);
				break;
			case "*":
				y = stack.pop();
				x = stack.pop();
				stack.push(x * y);
				break;
			default:
				stack.push(Integer.parseInt(inputline.get(i)));
			}
		} switch (inputline.get(i)) {
			case "+":
				y = stack.pop();
				x = stack.pop();
				stack.push(x + y);
				break;
			case "-":
				y = stack.pop();
				x = stack.pop();
				stack.push(x - y);
				break;
			case "*":
				y = stack.pop();
				x = stack.pop();
				stack.push(x * y);
				break;
			default:
				stack.push(Integer.parseInt(inputline.get(i)));
			} inputline.get(i) inputline.get inputline i case "+": "+" case "+": y = stack.pop() y stack.pop() stack.pop stack x = stack.pop() x stack.pop() stack.pop stack stack.push(x + y) stack.push stack x + y x y break; case "-": "-" case "-": y = stack.pop() y stack.pop() stack.pop stack x = stack.pop() x stack.pop() stack.pop stack stack.push(x - y) stack.push stack x - y x y break; case "*": "*" case "*": y = stack.pop() y stack.pop() stack.pop stack x = stack.pop() x stack.pop() stack.pop stack stack.push(x * y) stack.push stack x * y x y break; default: default: stack.push(Integer.parseInt(inputline.get(i))) stack.push stack Integer.parseInt(inputline.get(i)) Integer.parseInt Integer inputline.get(i) inputline.get inputline i System.out.println(stack.peek()) System.out.println System.out System System.out stack.peek() stack.peek stack String[] args args class Input {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	Input() {
		super();
	}

	public Integer getValue() {
		try {
			String[] s = br.readLine().trim().split(" ");
			return Integer.parseInt(s[0]);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	public List<Integer> getLine(int n) {
		List<Integer> values = new ArrayList<>();
		try {
			String[] s = br.readLine().trim().split(" ");
			for(int i = 0; i < n; i++) {
				values.add(Integer.parseInt(s[i]));
			}
			return values;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
	public List<String> getLineString() {
		try {
			String[] s = br.readLine().trim().split(" ");
			List<String> values = Arrays.asList(s);
			return values;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
} Input BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) Input() {
		super();
	} Input {
		super();
	} super() super public Integer getValue() {
		try {
			String[] s = br.readLine().trim().split(" ");
			return Integer.parseInt(s[0]);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	} getValue {
		try {
			String[] s = br.readLine().trim().split(" ");
			return Integer.parseInt(s[0]);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	} try {
			String[] s = br.readLine().trim().split(" ");
			return Integer.parseInt(s[0]);
		} catch (IOException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			String[] s = br.readLine().trim().split(" ");
			return Integer.parseInt(s[0]);
		} String[] s = br.readLine().trim().split(" "); s br.readLine().trim().split(" ") br.readLine().trim().split br.readLine().trim() br.readLine().trim br.readLine() br.readLine br " " return Integer.parseInt(s[0]); Integer.parseInt(s[0]) Integer.parseInt Integer s[0] s 0 return null; null public List<Integer> getLine(int n) {
		List<Integer> values = new ArrayList<>();
		try {
			String[] s = br.readLine().trim().split(" ");
			for(int i = 0; i < n; i++) {
				values.add(Integer.parseInt(s[i]));
			}
			return values;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	} getLine {
		List<Integer> values = new ArrayList<>();
		try {
			String[] s = br.readLine().trim().split(" ");
			for(int i = 0; i < n; i++) {
				values.add(Integer.parseInt(s[i]));
			}
			return values;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	} List<Integer> values = new ArrayList<>(); values new ArrayList<>() try {
			String[] s = br.readLine().trim().split(" ");
			for(int i = 0; i < n; i++) {
				values.add(Integer.parseInt(s[i]));
			}
			return values;
		} catch (IOException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			String[] s = br.readLine().trim().split(" ");
			for(int i = 0; i < n; i++) {
				values.add(Integer.parseInt(s[i]));
			}
			return values;
		} String[] s = br.readLine().trim().split(" "); s br.readLine().trim().split(" ") br.readLine().trim().split br.readLine().trim() br.readLine().trim br.readLine() br.readLine br " " for(int i = 0; i < n; i++) {
				values.add(Integer.parseInt(s[i]));
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				values.add(Integer.parseInt(s[i]));
			} {
				values.add(Integer.parseInt(s[i]));
			} values.add(Integer.parseInt(s[i])) values.add values Integer.parseInt(s[i]) Integer.parseInt Integer s[i] s i return values; values return null; null int n n public List<String> getLineString() {
		try {
			String[] s = br.readLine().trim().split(" ");
			List<String> values = Arrays.asList(s);
			return values;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	} getLineString {
		try {
			String[] s = br.readLine().trim().split(" ");
			List<String> values = Arrays.asList(s);
			return values;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	} try {
			String[] s = br.readLine().trim().split(" ");
			List<String> values = Arrays.asList(s);
			return values;
		} catch (IOException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			String[] s = br.readLine().trim().split(" ");
			List<String> values = Arrays.asList(s);
			return values;
		} String[] s = br.readLine().trim().split(" "); s br.readLine().trim().split(" ") br.readLine().trim().split br.readLine().trim() br.readLine().trim br.readLine() br.readLine br " " List<String> values = Arrays.asList(s); values Arrays.asList(s) Arrays.asList Arrays s return values; values return null; null
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;


class Main {

	public static void main(String[] args) {

		Input stdIn = new Input();
		int x, y;

		List<String> inputline = stdIn.getLineString();
		Deque<Integer> stack = new LinkedList<>();

		for (int i = 0; i < inputline.size(); i++) {
			switch (inputline.get(i)) {
			case "+":
				y = stack.pop();
				x = stack.pop();
				stack.push(x + y);
				break;
			case "-":
				y = stack.pop();
				x = stack.pop();
				stack.push(x - y);
				break;
			case "*":
				y = stack.pop();
				x = stack.pop();
				stack.push(x * y);
				break;
			default:
				stack.push(Integer.parseInt(inputline.get(i)));
			}
		}
		System.out.println(stack.peek());
	}
}
class Input {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	Input() {
		super();
	}

	public Integer getValue() {
		try {
			String[] s = br.readLine().trim().split(" ");
			return Integer.parseInt(s[0]);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	public List<Integer> getLine(int n) {
		List<Integer> values = new ArrayList<>();
		try {
			String[] s = br.readLine().trim().split(" ");
			for(int i = 0; i < n; i++) {
				values.add(Integer.parseInt(s[i]));
			}
			return values;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
	public List<String> getLineString() {
		try {
			String[] s = br.readLine().trim().split(" ");
			List<String> values = Arrays.asList(s);
			return values;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
}