import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<String> porand = new ArrayList<>(Arrays.asList(sc.nextLine().split(" ")));
		sc.close();
		List<String> stack = new ArrayList<>();
		for(String value: porand) {
			 if(isNumber(value)) {
				 push(stack, value);
			 } else {
				 String operand2 = pop(stack);
				 String operand1 = pop(stack);
				 String calcResult = calcResultGet(operand1, operand2, value);
				 push(stack, calcResult);
			 }
		}
		System.out.println(pop(stack));
	}
	public static void push(List<String> stack, String value) {
		stack.add(value);
	}
	public static String pop(List<String> stack) {
		int popIndex = stack.size() - 1;
		String value = stack.get(popIndex);
		stack.remove(popIndex);
		return value;
	}
	public static boolean isNumber(String value) {
		String numOnlyRegex = "[0-9]+";
		return value.matches(numOnlyRegex);
	}
	public static String calcResultGet(String operand1, String operand2, String enzanshi) {
		int operandNum1 = Integer.parseInt(operand1);
		int operandNum2 = Integer.parseInt(operand2);
		int calcResult = 0;
		switch (enzanshi) {
		case "+":
			calcResult = operandNum1 + operandNum2;
			break;

		case "-":
			calcResult = operandNum1 - operandNum2;
			break;

		case "*":
			calcResult = operandNum1 * operandNum2;
			break;
		}
		return String.valueOf(calcResult);
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<String> porand = new ArrayList<>(Arrays.asList(sc.nextLine().split(" ")));
		sc.close();
		List<String> stack = new ArrayList<>();
		for(String value: porand) {
			 if(isNumber(value)) {
				 push(stack, value);
			 } else {
				 String operand2 = pop(stack);
				 String operand1 = pop(stack);
				 String calcResult = calcResultGet(operand1, operand2, value);
				 push(stack, calcResult);
			 }
		}
		System.out.println(pop(stack));
	}
	public static void push(List<String> stack, String value) {
		stack.add(value);
	}
	public static String pop(List<String> stack) {
		int popIndex = stack.size() - 1;
		String value = stack.get(popIndex);
		stack.remove(popIndex);
		return value;
	}
	public static boolean isNumber(String value) {
		String numOnlyRegex = "[0-9]+";
		return value.matches(numOnlyRegex);
	}
	public static String calcResultGet(String operand1, String operand2, String enzanshi) {
		int operandNum1 = Integer.parseInt(operand1);
		int operandNum2 = Integer.parseInt(operand2);
		int calcResult = 0;
		switch (enzanshi) {
		case "+":
			calcResult = operandNum1 + operandNum2;
			break;

		case "-":
			calcResult = operandNum1 - operandNum2;
			break;

		case "*":
			calcResult = operandNum1 * operandNum2;
			break;
		}
		return String.valueOf(calcResult);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<String> porand = new ArrayList<>(Arrays.asList(sc.nextLine().split(" ")));
		sc.close();
		List<String> stack = new ArrayList<>();
		for(String value: porand) {
			 if(isNumber(value)) {
				 push(stack, value);
			 } else {
				 String operand2 = pop(stack);
				 String operand1 = pop(stack);
				 String calcResult = calcResultGet(operand1, operand2, value);
				 push(stack, calcResult);
			 }
		}
		System.out.println(pop(stack));
	} main {
		Scanner sc = new Scanner(System.in);
		List<String> porand = new ArrayList<>(Arrays.asList(sc.nextLine().split(" ")));
		sc.close();
		List<String> stack = new ArrayList<>();
		for(String value: porand) {
			 if(isNumber(value)) {
				 push(stack, value);
			 } else {
				 String operand2 = pop(stack);
				 String operand1 = pop(stack);
				 String calcResult = calcResultGet(operand1, operand2, value);
				 push(stack, calcResult);
			 }
		}
		System.out.println(pop(stack));
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) List<String> porand = new ArrayList<>(Arrays.asList(sc.nextLine().split(" "))); porand new ArrayList<>(Arrays.asList(sc.nextLine().split(" "))) sc.close() sc.close sc List<String> stack = new ArrayList<>(); stack new ArrayList<>() for(String value: porand) {
			 if(isNumber(value)) {
				 push(stack, value);
			 } else {
				 String operand2 = pop(stack);
				 String operand1 = pop(stack);
				 String calcResult = calcResultGet(operand1, operand2, value);
				 push(stack, calcResult);
			 }
		} String value porand {
			 if(isNumber(value)) {
				 push(stack, value);
			 } else {
				 String operand2 = pop(stack);
				 String operand1 = pop(stack);
				 String calcResult = calcResultGet(operand1, operand2, value);
				 push(stack, calcResult);
			 }
		} {
			 if(isNumber(value)) {
				 push(stack, value);
			 } else {
				 String operand2 = pop(stack);
				 String operand1 = pop(stack);
				 String calcResult = calcResultGet(operand1, operand2, value);
				 push(stack, calcResult);
			 }
		} if(isNumber(value)) {
				 push(stack, value);
			 } else {
				 String operand2 = pop(stack);
				 String operand1 = pop(stack);
				 String calcResult = calcResultGet(operand1, operand2, value);
				 push(stack, calcResult);
			 } isNumber(value) isNumber value {
				 push(stack, value);
			 } push(stack, value) push stack value {
				 String operand2 = pop(stack);
				 String operand1 = pop(stack);
				 String calcResult = calcResultGet(operand1, operand2, value);
				 push(stack, calcResult);
			 } String operand2 = pop(stack); operand2 pop(stack) pop stack String operand1 = pop(stack); operand1 pop(stack) pop stack String calcResult = calcResultGet(operand1, operand2, value); calcResult calcResultGet(operand1, operand2, value) calcResultGet operand1 operand2 value push(stack, calcResult) push stack calcResult System.out.println(pop(stack)) System.out.println System.out System System.out pop(stack) pop stack String[] args args public static void push(List<String> stack, String value) {
		stack.add(value);
	} push {
		stack.add(value);
	} stack.add(value) stack.add stack value List<String> stack stack String value value public static String pop(List<String> stack) {
		int popIndex = stack.size() - 1;
		String value = stack.get(popIndex);
		stack.remove(popIndex);
		return value;
	} pop {
		int popIndex = stack.size() - 1;
		String value = stack.get(popIndex);
		stack.remove(popIndex);
		return value;
	} int popIndex = stack.size() - 1; popIndex stack.size() - 1 stack.size() stack.size stack 1 String value = stack.get(popIndex); value stack.get(popIndex) stack.get stack popIndex stack.remove(popIndex) stack.remove stack popIndex return value; value List<String> stack stack public static boolean isNumber(String value) {
		String numOnlyRegex = "[0-9]+";
		return value.matches(numOnlyRegex);
	} isNumber {
		String numOnlyRegex = "[0-9]+";
		return value.matches(numOnlyRegex);
	} String numOnlyRegex = "[0-9]+"; numOnlyRegex "[0-9]+" return value.matches(numOnlyRegex); value.matches(numOnlyRegex) value.matches value numOnlyRegex String value value public static String calcResultGet(String operand1, String operand2, String enzanshi) {
		int operandNum1 = Integer.parseInt(operand1);
		int operandNum2 = Integer.parseInt(operand2);
		int calcResult = 0;
		switch (enzanshi) {
		case "+":
			calcResult = operandNum1 + operandNum2;
			break;

		case "-":
			calcResult = operandNum1 - operandNum2;
			break;

		case "*":
			calcResult = operandNum1 * operandNum2;
			break;
		}
		return String.valueOf(calcResult);
	} calcResultGet {
		int operandNum1 = Integer.parseInt(operand1);
		int operandNum2 = Integer.parseInt(operand2);
		int calcResult = 0;
		switch (enzanshi) {
		case "+":
			calcResult = operandNum1 + operandNum2;
			break;

		case "-":
			calcResult = operandNum1 - operandNum2;
			break;

		case "*":
			calcResult = operandNum1 * operandNum2;
			break;
		}
		return String.valueOf(calcResult);
	} int operandNum1 = Integer.parseInt(operand1); operandNum1 Integer.parseInt(operand1) Integer.parseInt Integer operand1 int operandNum2 = Integer.parseInt(operand2); operandNum2 Integer.parseInt(operand2) Integer.parseInt Integer operand2 int calcResult = 0; calcResult 0 switch (enzanshi) {
		case "+":
			calcResult = operandNum1 + operandNum2;
			break;

		case "-":
			calcResult = operandNum1 - operandNum2;
			break;

		case "*":
			calcResult = operandNum1 * operandNum2;
			break;
		} enzanshi case "+": "+" case "+": calcResult = operandNum1 + operandNum2 calcResult operandNum1 + operandNum2 operandNum1 operandNum2 break; case "-": "-" case "-": calcResult = operandNum1 - operandNum2 calcResult operandNum1 - operandNum2 operandNum1 operandNum2 break; case "*": "*" case "*": calcResult = operandNum1 * operandNum2 calcResult operandNum1 * operandNum2 operandNum1 operandNum2 break; return String.valueOf(calcResult); String.valueOf(calcResult) String.valueOf String calcResult String operand1 operand1 String operand2 operand2 String enzanshi enzanshi public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<String> porand = new ArrayList<>(Arrays.asList(sc.nextLine().split(" ")));
		sc.close();
		List<String> stack = new ArrayList<>();
		for(String value: porand) {
			 if(isNumber(value)) {
				 push(stack, value);
			 } else {
				 String operand2 = pop(stack);
				 String operand1 = pop(stack);
				 String calcResult = calcResultGet(operand1, operand2, value);
				 push(stack, calcResult);
			 }
		}
		System.out.println(pop(stack));
	}
	public static void push(List<String> stack, String value) {
		stack.add(value);
	}
	public static String pop(List<String> stack) {
		int popIndex = stack.size() - 1;
		String value = stack.get(popIndex);
		stack.remove(popIndex);
		return value;
	}
	public static boolean isNumber(String value) {
		String numOnlyRegex = "[0-9]+";
		return value.matches(numOnlyRegex);
	}
	public static String calcResultGet(String operand1, String operand2, String enzanshi) {
		int operandNum1 = Integer.parseInt(operand1);
		int operandNum2 = Integer.parseInt(operand2);
		int calcResult = 0;
		switch (enzanshi) {
		case "+":
			calcResult = operandNum1 + operandNum2;
			break;

		case "-":
			calcResult = operandNum1 - operandNum2;
			break;

		case "*":
			calcResult = operandNum1 * operandNum2;
			break;
		}
		return String.valueOf(calcResult);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<String> porand = new ArrayList<>(Arrays.asList(sc.nextLine().split(" ")));
		sc.close();
		List<String> stack = new ArrayList<>();
		for(String value: porand) {
			 if(isNumber(value)) {
				 push(stack, value);
			 } else {
				 String operand2 = pop(stack);
				 String operand1 = pop(stack);
				 String calcResult = calcResultGet(operand1, operand2, value);
				 push(stack, calcResult);
			 }
		}
		System.out.println(pop(stack));
	}
	public static void push(List<String> stack, String value) {
		stack.add(value);
	}
	public static String pop(List<String> stack) {
		int popIndex = stack.size() - 1;
		String value = stack.get(popIndex);
		stack.remove(popIndex);
		return value;
	}
	public static boolean isNumber(String value) {
		String numOnlyRegex = "[0-9]+";
		return value.matches(numOnlyRegex);
	}
	public static String calcResultGet(String operand1, String operand2, String enzanshi) {
		int operandNum1 = Integer.parseInt(operand1);
		int operandNum2 = Integer.parseInt(operand2);
		int calcResult = 0;
		switch (enzanshi) {
		case "+":
			calcResult = operandNum1 + operandNum2;
			break;

		case "-":
			calcResult = operandNum1 - operandNum2;
			break;

		case "*":
			calcResult = operandNum1 * operandNum2;
			break;
		}
		return String.valueOf(calcResult);
	}
} Main
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<String> porand = new ArrayList<>(Arrays.asList(sc.nextLine().split(" ")));
		sc.close();
		List<String> stack = new ArrayList<>();
		for(String value: porand) {
			 if(isNumber(value)) {
				 push(stack, value);
			 } else {
				 String operand2 = pop(stack);
				 String operand1 = pop(stack);
				 String calcResult = calcResultGet(operand1, operand2, value);
				 push(stack, calcResult);
			 }
		}
		System.out.println(pop(stack));
	}
	public static void push(List<String> stack, String value) {
		stack.add(value);
	}
	public static String pop(List<String> stack) {
		int popIndex = stack.size() - 1;
		String value = stack.get(popIndex);
		stack.remove(popIndex);
		return value;
	}
	public static boolean isNumber(String value) {
		String numOnlyRegex = "[0-9]+";
		return value.matches(numOnlyRegex);
	}
	public static String calcResultGet(String operand1, String operand2, String enzanshi) {
		int operandNum1 = Integer.parseInt(operand1);
		int operandNum2 = Integer.parseInt(operand2);
		int calcResult = 0;
		switch (enzanshi) {
		case "+":
			calcResult = operandNum1 + operandNum2;
			break;

		case "-":
			calcResult = operandNum1 - operandNum2;
			break;

		case "*":
			calcResult = operandNum1 * operandNum2;
			break;
		}
		return String.valueOf(calcResult);
	}
}