import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) throws IOException {
		final String[] expression = getExpression();
		
		final String answer = calclate(expression);
		System.out.println(answer);
	}
	
	public static String calclate(final String[] expression) {
		final Stack<String> stack = new Stack<String>();
		
		for (String term : expression) {
			
			if (isNumber(term)) {
				stack.push(term);
				
			} else {
				final int operand2 = Integer.parseInt(stack.pop());
				final int operand1 = Integer.parseInt(stack.pop());
				
				String result;
				if ("+".equals(term)) {
					result = String.valueOf(operand1 + operand2);
					
				} else if ("-".equals(term)) {
					result = String.valueOf(operand1 - operand2);
					
				} else {
					result = String.valueOf(operand1 * operand2);
				}
				stack.push(result);
			}
		}
		
		return stack.pop();
	}
	
	public static boolean isNumber(String term) {
		Pattern patternNum = Pattern.compile("-*[0-9]+");
		Matcher matcherNum = patternNum.matcher(term);
		
		return matcherNum.matches();
	}
	
	public static String[] getExpression() throws IOException {
		final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		final String[] expression = reader.readLine().split(" ");
		reader.close();
		
		return expression;
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Stack; Stack java.util import java.util.regex.Matcher; Matcher java.util.regex import java.util.regex.Pattern; Pattern java.util.regex public class Main {
	public static void main(String[] args) throws IOException {
		final String[] expression = getExpression();
		
		final String answer = calclate(expression);
		System.out.println(answer);
	}
	
	public static String calclate(final String[] expression) {
		final Stack<String> stack = new Stack<String>();
		
		for (String term : expression) {
			
			if (isNumber(term)) {
				stack.push(term);
				
			} else {
				final int operand2 = Integer.parseInt(stack.pop());
				final int operand1 = Integer.parseInt(stack.pop());
				
				String result;
				if ("+".equals(term)) {
					result = String.valueOf(operand1 + operand2);
					
				} else if ("-".equals(term)) {
					result = String.valueOf(operand1 - operand2);
					
				} else {
					result = String.valueOf(operand1 * operand2);
				}
				stack.push(result);
			}
		}
		
		return stack.pop();
	}
	
	public static boolean isNumber(String term) {
		Pattern patternNum = Pattern.compile("-*[0-9]+");
		Matcher matcherNum = patternNum.matcher(term);
		
		return matcherNum.matches();
	}
	
	public static String[] getExpression() throws IOException {
		final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		final String[] expression = reader.readLine().split(" ");
		reader.close();
		
		return expression;
	}
} Main public static void main(String[] args) throws IOException {
		final String[] expression = getExpression();
		
		final String answer = calclate(expression);
		System.out.println(answer);
	} main {
		final String[] expression = getExpression();
		
		final String answer = calclate(expression);
		System.out.println(answer);
	} final String[] expression = getExpression(); expression getExpression() getExpression final String answer = calclate(expression); answer calclate(expression) calclate expression System.out.println(answer) System.out.println System.out System System.out answer String[] args args public static String calclate(final String[] expression) {
		final Stack<String> stack = new Stack<String>();
		
		for (String term : expression) {
			
			if (isNumber(term)) {
				stack.push(term);
				
			} else {
				final int operand2 = Integer.parseInt(stack.pop());
				final int operand1 = Integer.parseInt(stack.pop());
				
				String result;
				if ("+".equals(term)) {
					result = String.valueOf(operand1 + operand2);
					
				} else if ("-".equals(term)) {
					result = String.valueOf(operand1 - operand2);
					
				} else {
					result = String.valueOf(operand1 * operand2);
				}
				stack.push(result);
			}
		}
		
		return stack.pop();
	} calclate {
		final Stack<String> stack = new Stack<String>();
		
		for (String term : expression) {
			
			if (isNumber(term)) {
				stack.push(term);
				
			} else {
				final int operand2 = Integer.parseInt(stack.pop());
				final int operand1 = Integer.parseInt(stack.pop());
				
				String result;
				if ("+".equals(term)) {
					result = String.valueOf(operand1 + operand2);
					
				} else if ("-".equals(term)) {
					result = String.valueOf(operand1 - operand2);
					
				} else {
					result = String.valueOf(operand1 * operand2);
				}
				stack.push(result);
			}
		}
		
		return stack.pop();
	} final Stack<String> stack = new Stack<String>(); stack new Stack<String>() for (String term : expression) {
			
			if (isNumber(term)) {
				stack.push(term);
				
			} else {
				final int operand2 = Integer.parseInt(stack.pop());
				final int operand1 = Integer.parseInt(stack.pop());
				
				String result;
				if ("+".equals(term)) {
					result = String.valueOf(operand1 + operand2);
					
				} else if ("-".equals(term)) {
					result = String.valueOf(operand1 - operand2);
					
				} else {
					result = String.valueOf(operand1 * operand2);
				}
				stack.push(result);
			}
		} String term expression {
			
			if (isNumber(term)) {
				stack.push(term);
				
			} else {
				final int operand2 = Integer.parseInt(stack.pop());
				final int operand1 = Integer.parseInt(stack.pop());
				
				String result;
				if ("+".equals(term)) {
					result = String.valueOf(operand1 + operand2);
					
				} else if ("-".equals(term)) {
					result = String.valueOf(operand1 - operand2);
					
				} else {
					result = String.valueOf(operand1 * operand2);
				}
				stack.push(result);
			}
		} {
			
			if (isNumber(term)) {
				stack.push(term);
				
			} else {
				final int operand2 = Integer.parseInt(stack.pop());
				final int operand1 = Integer.parseInt(stack.pop());
				
				String result;
				if ("+".equals(term)) {
					result = String.valueOf(operand1 + operand2);
					
				} else if ("-".equals(term)) {
					result = String.valueOf(operand1 - operand2);
					
				} else {
					result = String.valueOf(operand1 * operand2);
				}
				stack.push(result);
			}
		} if (isNumber(term)) {
				stack.push(term);
				
			} else {
				final int operand2 = Integer.parseInt(stack.pop());
				final int operand1 = Integer.parseInt(stack.pop());
				
				String result;
				if ("+".equals(term)) {
					result = String.valueOf(operand1 + operand2);
					
				} else if ("-".equals(term)) {
					result = String.valueOf(operand1 - operand2);
					
				} else {
					result = String.valueOf(operand1 * operand2);
				}
				stack.push(result);
			} isNumber(term) isNumber term {
				stack.push(term);
				
			} stack.push(term) stack.push stack term {
				final int operand2 = Integer.parseInt(stack.pop());
				final int operand1 = Integer.parseInt(stack.pop());
				
				String result;
				if ("+".equals(term)) {
					result = String.valueOf(operand1 + operand2);
					
				} else if ("-".equals(term)) {
					result = String.valueOf(operand1 - operand2);
					
				} else {
					result = String.valueOf(operand1 * operand2);
				}
				stack.push(result);
			} final int operand2 = Integer.parseInt(stack.pop()); operand2 Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack final int operand1 = Integer.parseInt(stack.pop()); operand1 Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack String result; result if ("+".equals(term)) {
					result = String.valueOf(operand1 + operand2);
					
				} else if ("-".equals(term)) {
					result = String.valueOf(operand1 - operand2);
					
				} else {
					result = String.valueOf(operand1 * operand2);
				} "+".equals(term) "+".equals "+" term {
					result = String.valueOf(operand1 + operand2);
					
				} result = String.valueOf(operand1 + operand2) result String.valueOf(operand1 + operand2) String.valueOf String operand1 + operand2 operand1 operand2 if ("-".equals(term)) {
					result = String.valueOf(operand1 - operand2);
					
				} else {
					result = String.valueOf(operand1 * operand2);
				} "-".equals(term) "-".equals "-" term {
					result = String.valueOf(operand1 - operand2);
					
				} result = String.valueOf(operand1 - operand2) result String.valueOf(operand1 - operand2) String.valueOf String operand1 - operand2 operand1 operand2 {
					result = String.valueOf(operand1 * operand2);
				} result = String.valueOf(operand1 * operand2) result String.valueOf(operand1 * operand2) String.valueOf String operand1 * operand2 operand1 operand2 stack.push(result) stack.push stack result return stack.pop(); stack.pop() stack.pop stack final String[] expression expression public static boolean isNumber(String term) {
		Pattern patternNum = Pattern.compile("-*[0-9]+");
		Matcher matcherNum = patternNum.matcher(term);
		
		return matcherNum.matches();
	} isNumber {
		Pattern patternNum = Pattern.compile("-*[0-9]+");
		Matcher matcherNum = patternNum.matcher(term);
		
		return matcherNum.matches();
	} Pattern patternNum = Pattern.compile("-*[0-9]+"); patternNum Pattern.compile("-*[0-9]+") Pattern.compile Pattern "-*[0-9]+" Matcher matcherNum = patternNum.matcher(term); matcherNum patternNum.matcher(term) patternNum.matcher patternNum term return matcherNum.matches(); matcherNum.matches() matcherNum.matches matcherNum String term term public static String[] getExpression() throws IOException {
		final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		final String[] expression = reader.readLine().split(" ");
		reader.close();
		
		return expression;
	} getExpression {
		final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		final String[] expression = reader.readLine().split(" ");
		reader.close();
		
		return expression;
	} final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) final String[] expression = reader.readLine().split(" "); expression reader.readLine().split(" ") reader.readLine().split reader.readLine() reader.readLine reader " " reader.close() reader.close reader return expression; expression public class Main {
	public static void main(String[] args) throws IOException {
		final String[] expression = getExpression();
		
		final String answer = calclate(expression);
		System.out.println(answer);
	}
	
	public static String calclate(final String[] expression) {
		final Stack<String> stack = new Stack<String>();
		
		for (String term : expression) {
			
			if (isNumber(term)) {
				stack.push(term);
				
			} else {
				final int operand2 = Integer.parseInt(stack.pop());
				final int operand1 = Integer.parseInt(stack.pop());
				
				String result;
				if ("+".equals(term)) {
					result = String.valueOf(operand1 + operand2);
					
				} else if ("-".equals(term)) {
					result = String.valueOf(operand1 - operand2);
					
				} else {
					result = String.valueOf(operand1 * operand2);
				}
				stack.push(result);
			}
		}
		
		return stack.pop();
	}
	
	public static boolean isNumber(String term) {
		Pattern patternNum = Pattern.compile("-*[0-9]+");
		Matcher matcherNum = patternNum.matcher(term);
		
		return matcherNum.matches();
	}
	
	public static String[] getExpression() throws IOException {
		final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		final String[] expression = reader.readLine().split(" ");
		reader.close();
		
		return expression;
	}
} public class Main {
	public static void main(String[] args) throws IOException {
		final String[] expression = getExpression();
		
		final String answer = calclate(expression);
		System.out.println(answer);
	}
	
	public static String calclate(final String[] expression) {
		final Stack<String> stack = new Stack<String>();
		
		for (String term : expression) {
			
			if (isNumber(term)) {
				stack.push(term);
				
			} else {
				final int operand2 = Integer.parseInt(stack.pop());
				final int operand1 = Integer.parseInt(stack.pop());
				
				String result;
				if ("+".equals(term)) {
					result = String.valueOf(operand1 + operand2);
					
				} else if ("-".equals(term)) {
					result = String.valueOf(operand1 - operand2);
					
				} else {
					result = String.valueOf(operand1 * operand2);
				}
				stack.push(result);
			}
		}
		
		return stack.pop();
	}
	
	public static boolean isNumber(String term) {
		Pattern patternNum = Pattern.compile("-*[0-9]+");
		Matcher matcherNum = patternNum.matcher(term);
		
		return matcherNum.matches();
	}
	
	public static String[] getExpression() throws IOException {
		final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		final String[] expression = reader.readLine().split(" ");
		reader.close();
		
		return expression;
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) throws IOException {
		final String[] expression = getExpression();
		
		final String answer = calclate(expression);
		System.out.println(answer);
	}
	
	public static String calclate(final String[] expression) {
		final Stack<String> stack = new Stack<String>();
		
		for (String term : expression) {
			
			if (isNumber(term)) {
				stack.push(term);
				
			} else {
				final int operand2 = Integer.parseInt(stack.pop());
				final int operand1 = Integer.parseInt(stack.pop());
				
				String result;
				if ("+".equals(term)) {
					result = String.valueOf(operand1 + operand2);
					
				} else if ("-".equals(term)) {
					result = String.valueOf(operand1 - operand2);
					
				} else {
					result = String.valueOf(operand1 * operand2);
				}
				stack.push(result);
			}
		}
		
		return stack.pop();
	}
	
	public static boolean isNumber(String term) {
		Pattern patternNum = Pattern.compile("-*[0-9]+");
		Matcher matcherNum = patternNum.matcher(term);
		
		return matcherNum.matches();
	}
	
	public static String[] getExpression() throws IOException {
		final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		final String[] expression = reader.readLine().split(" ");
		reader.close();
		
		return expression;
	}
}