

import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		ArrayDeque<Integer> stack = new ArrayDeque<>(); //Stack???????????£????????§?????????
		
		Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] lineArr = line.split(" ");
        
        
		for(String item: lineArr){
			if (item.equals("+")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second + first);
			}else if (item.equals("-")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second - first);
			}else if (item.equals("*")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second * first);
			}else { // ??°???
				stack.offerFirst(Integer.parseInt(item));
			}
		}
		System.out.println(stack.pollFirst());
		sc.close();
	}

	
} import java.util.ArrayDeque; ArrayDeque java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		ArrayDeque<Integer> stack = new ArrayDeque<>(); //Stack???????????£????????§?????????
		
		Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] lineArr = line.split(" ");
        
        
		for(String item: lineArr){
			if (item.equals("+")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second + first);
			}else if (item.equals("-")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second - first);
			}else if (item.equals("*")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second * first);
			}else { // ??°???
				stack.offerFirst(Integer.parseInt(item));
			}
		}
		System.out.println(stack.pollFirst());
		sc.close();
	}

	
} Main public static void main(String[] args) {
		ArrayDeque<Integer> stack = new ArrayDeque<>(); //Stack???????????£????????§?????????
		
		Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] lineArr = line.split(" ");
        
        
		for(String item: lineArr){
			if (item.equals("+")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second + first);
			}else if (item.equals("-")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second - first);
			}else if (item.equals("*")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second * first);
			}else { // ??°???
				stack.offerFirst(Integer.parseInt(item));
			}
		}
		System.out.println(stack.pollFirst());
		sc.close();
	} main {
		ArrayDeque<Integer> stack = new ArrayDeque<>(); //Stack???????????£????????§?????????
		
		Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] lineArr = line.split(" ");
        
        
		for(String item: lineArr){
			if (item.equals("+")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second + first);
			}else if (item.equals("-")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second - first);
			}else if (item.equals("*")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second * first);
			}else { // ??°???
				stack.offerFirst(Integer.parseInt(item));
			}
		}
		System.out.println(stack.pollFirst());
		sc.close();
	} ArrayDeque<Integer> stack = new ArrayDeque<>(); stack new ArrayDeque<>() Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc String[] lineArr = line.split(" "); lineArr line.split(" ") line.split line " " for(String item: lineArr){
			if (item.equals("+")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second + first);
			}else if (item.equals("-")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second - first);
			}else if (item.equals("*")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second * first);
			}else { // ??°???
				stack.offerFirst(Integer.parseInt(item));
			}
		} String item lineArr {
			if (item.equals("+")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second + first);
			}else if (item.equals("-")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second - first);
			}else if (item.equals("*")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second * first);
			}else { // ??°???
				stack.offerFirst(Integer.parseInt(item));
			}
		} {
			if (item.equals("+")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second + first);
			}else if (item.equals("-")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second - first);
			}else if (item.equals("*")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second * first);
			}else { // ??°???
				stack.offerFirst(Integer.parseInt(item));
			}
		} if (item.equals("+")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second + first);
			}else if (item.equals("-")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second - first);
			}else if (item.equals("*")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second * first);
			}else { // ??°???
				stack.offerFirst(Integer.parseInt(item));
			} item.equals("+") item.equals item "+" {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second + first);
			} int first = stack.pollFirst(); first stack.pollFirst() stack.pollFirst stack int second = stack.pollFirst(); second stack.pollFirst() stack.pollFirst stack stack.offerFirst(second + first) stack.offerFirst stack second + first second first if (item.equals("-")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second - first);
			}else if (item.equals("*")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second * first);
			}else { // ??°???
				stack.offerFirst(Integer.parseInt(item));
			} item.equals("-") item.equals item "-" {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second - first);
			} int first = stack.pollFirst(); first stack.pollFirst() stack.pollFirst stack int second = stack.pollFirst(); second stack.pollFirst() stack.pollFirst stack stack.offerFirst(second - first) stack.offerFirst stack second - first second first if (item.equals("*")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second * first);
			}else { // ??°???
				stack.offerFirst(Integer.parseInt(item));
			} item.equals("*") item.equals item "*" {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second * first);
			} int first = stack.pollFirst(); first stack.pollFirst() stack.pollFirst stack int second = stack.pollFirst(); second stack.pollFirst() stack.pollFirst stack stack.offerFirst(second * first) stack.offerFirst stack second * first second first { // ??°???
				stack.offerFirst(Integer.parseInt(item));
			} stack.offerFirst(Integer.parseInt(item)) stack.offerFirst stack Integer.parseInt(item) Integer.parseInt Integer item System.out.println(stack.pollFirst()) System.out.println System.out System System.out stack.pollFirst() stack.pollFirst stack sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {
		ArrayDeque<Integer> stack = new ArrayDeque<>(); //Stack???????????£????????§?????????
		
		Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] lineArr = line.split(" ");
        
        
		for(String item: lineArr){
			if (item.equals("+")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second + first);
			}else if (item.equals("-")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second - first);
			}else if (item.equals("*")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second * first);
			}else { // ??°???
				stack.offerFirst(Integer.parseInt(item));
			}
		}
		System.out.println(stack.pollFirst());
		sc.close();
	}

	
} public class Main {

	public static void main(String[] args) {
		ArrayDeque<Integer> stack = new ArrayDeque<>(); //Stack???????????£????????§?????????
		
		Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] lineArr = line.split(" ");
        
        
		for(String item: lineArr){
			if (item.equals("+")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second + first);
			}else if (item.equals("-")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second - first);
			}else if (item.equals("*")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second * first);
			}else { // ??°???
				stack.offerFirst(Integer.parseInt(item));
			}
		}
		System.out.println(stack.pollFirst());
		sc.close();
	}

	
} Main


import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		ArrayDeque<Integer> stack = new ArrayDeque<>(); //Stack???????????£????????§?????????
		
		Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] lineArr = line.split(" ");
        
        
		for(String item: lineArr){
			if (item.equals("+")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second + first);
			}else if (item.equals("-")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second - first);
			}else if (item.equals("*")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second * first);
			}else { // ??°???
				stack.offerFirst(Integer.parseInt(item));
			}
		}
		System.out.println(stack.pollFirst());
		sc.close();
	}

	
}