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

public class Main {
	public static final String plus = "+";
	public static final String minus = "-";
	public static final String kake = "*";
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		String strInt = null;
		int intStr = 0;
		int numInt1 = 0;
		int numInt2 = 0;
		int total = 0;
		List<Integer> stack = new ArrayList<Integer>(100);
		while(sc.hasNext()){
			strInt = sc.next();
			if(strInt.equals(plus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 + numInt2;
				stack.add(total);
			}else if(strInt.equals(minus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 - numInt2;
				stack.add(total);
			}else if(strInt.equalsIgnoreCase(kake)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 * numInt2;
				stack.add(total);
			}else{
				intStr = Integer.parseInt(strInt);
				stack.add(intStr);
			}
		}
		total = stack.get(stack.size() - 1);
		System.out.println(total);
	}
} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
	public static final String plus = "+";
	public static final String minus = "-";
	public static final String kake = "*";
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		String strInt = null;
		int intStr = 0;
		int numInt1 = 0;
		int numInt2 = 0;
		int total = 0;
		List<Integer> stack = new ArrayList<Integer>(100);
		while(sc.hasNext()){
			strInt = sc.next();
			if(strInt.equals(plus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 + numInt2;
				stack.add(total);
			}else if(strInt.equals(minus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 - numInt2;
				stack.add(total);
			}else if(strInt.equalsIgnoreCase(kake)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 * numInt2;
				stack.add(total);
			}else{
				intStr = Integer.parseInt(strInt);
				stack.add(intStr);
			}
		}
		total = stack.get(stack.size() - 1);
		System.out.println(total);
	}
} Main public static final String plus = "+"; plus "+" public static final String minus = "-"; minus "-" public static final String kake = "*"; kake "*" public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		String strInt = null;
		int intStr = 0;
		int numInt1 = 0;
		int numInt2 = 0;
		int total = 0;
		List<Integer> stack = new ArrayList<Integer>(100);
		while(sc.hasNext()){
			strInt = sc.next();
			if(strInt.equals(plus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 + numInt2;
				stack.add(total);
			}else if(strInt.equals(minus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 - numInt2;
				stack.add(total);
			}else if(strInt.equalsIgnoreCase(kake)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 * numInt2;
				stack.add(total);
			}else{
				intStr = Integer.parseInt(strInt);
				stack.add(intStr);
			}
		}
		total = stack.get(stack.size() - 1);
		System.out.println(total);
	} main {
    	Scanner sc = new Scanner(System.in);
		String strInt = null;
		int intStr = 0;
		int numInt1 = 0;
		int numInt2 = 0;
		int total = 0;
		List<Integer> stack = new ArrayList<Integer>(100);
		while(sc.hasNext()){
			strInt = sc.next();
			if(strInt.equals(plus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 + numInt2;
				stack.add(total);
			}else if(strInt.equals(minus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 - numInt2;
				stack.add(total);
			}else if(strInt.equalsIgnoreCase(kake)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 * numInt2;
				stack.add(total);
			}else{
				intStr = Integer.parseInt(strInt);
				stack.add(intStr);
			}
		}
		total = stack.get(stack.size() - 1);
		System.out.println(total);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String strInt = null; strInt null int intStr = 0; intStr 0 int numInt1 = 0; numInt1 0 int numInt2 = 0; numInt2 0 int total = 0; total 0 List<Integer> stack = new ArrayList<Integer>(100); stack new ArrayList<Integer>(100) while(sc.hasNext()){
			strInt = sc.next();
			if(strInt.equals(plus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 + numInt2;
				stack.add(total);
			}else if(strInt.equals(minus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 - numInt2;
				stack.add(total);
			}else if(strInt.equalsIgnoreCase(kake)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 * numInt2;
				stack.add(total);
			}else{
				intStr = Integer.parseInt(strInt);
				stack.add(intStr);
			}
		} sc.hasNext() sc.hasNext sc {
			strInt = sc.next();
			if(strInt.equals(plus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 + numInt2;
				stack.add(total);
			}else if(strInt.equals(minus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 - numInt2;
				stack.add(total);
			}else if(strInt.equalsIgnoreCase(kake)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 * numInt2;
				stack.add(total);
			}else{
				intStr = Integer.parseInt(strInt);
				stack.add(intStr);
			}
		} strInt = sc.next() strInt sc.next() sc.next sc if(strInt.equals(plus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 + numInt2;
				stack.add(total);
			}else if(strInt.equals(minus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 - numInt2;
				stack.add(total);
			}else if(strInt.equalsIgnoreCase(kake)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 * numInt2;
				stack.add(total);
			}else{
				intStr = Integer.parseInt(strInt);
				stack.add(intStr);
			} strInt.equals(plus) strInt.equals strInt plus {
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 + numInt2;
				stack.add(total);
			} numInt2 = stack.get(stack.size() - 1) numInt2 stack.get(stack.size() - 1) stack.get stack stack.size() - 1 stack.size() stack.size stack 1 stack.remove(stack.size() - 1) stack.remove stack stack.size() - 1 stack.size() stack.size stack 1 numInt1 = stack.get(stack.size() - 1) numInt1 stack.get(stack.size() - 1) stack.get stack stack.size() - 1 stack.size() stack.size stack 1 stack.remove(stack.size() - 1) stack.remove stack stack.size() - 1 stack.size() stack.size stack 1 total = numInt1 + numInt2 total numInt1 + numInt2 numInt1 numInt2 stack.add(total) stack.add stack total if(strInt.equals(minus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 - numInt2;
				stack.add(total);
			}else if(strInt.equalsIgnoreCase(kake)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 * numInt2;
				stack.add(total);
			}else{
				intStr = Integer.parseInt(strInt);
				stack.add(intStr);
			} strInt.equals(minus) strInt.equals strInt minus {
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 - numInt2;
				stack.add(total);
			} numInt2 = stack.get(stack.size() - 1) numInt2 stack.get(stack.size() - 1) stack.get stack stack.size() - 1 stack.size() stack.size stack 1 stack.remove(stack.size() - 1) stack.remove stack stack.size() - 1 stack.size() stack.size stack 1 numInt1 = stack.get(stack.size() - 1) numInt1 stack.get(stack.size() - 1) stack.get stack stack.size() - 1 stack.size() stack.size stack 1 stack.remove(stack.size() - 1) stack.remove stack stack.size() - 1 stack.size() stack.size stack 1 total = numInt1 - numInt2 total numInt1 - numInt2 numInt1 numInt2 stack.add(total) stack.add stack total if(strInt.equalsIgnoreCase(kake)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 * numInt2;
				stack.add(total);
			}else{
				intStr = Integer.parseInt(strInt);
				stack.add(intStr);
			} strInt.equalsIgnoreCase(kake) strInt.equalsIgnoreCase strInt kake {
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 * numInt2;
				stack.add(total);
			} numInt2 = stack.get(stack.size() - 1) numInt2 stack.get(stack.size() - 1) stack.get stack stack.size() - 1 stack.size() stack.size stack 1 stack.remove(stack.size() - 1) stack.remove stack stack.size() - 1 stack.size() stack.size stack 1 numInt1 = stack.get(stack.size() - 1) numInt1 stack.get(stack.size() - 1) stack.get stack stack.size() - 1 stack.size() stack.size stack 1 stack.remove(stack.size() - 1) stack.remove stack stack.size() - 1 stack.size() stack.size stack 1 total = numInt1 * numInt2 total numInt1 * numInt2 numInt1 numInt2 stack.add(total) stack.add stack total {
				intStr = Integer.parseInt(strInt);
				stack.add(intStr);
			} intStr = Integer.parseInt(strInt) intStr Integer.parseInt(strInt) Integer.parseInt Integer strInt stack.add(intStr) stack.add stack intStr total = stack.get(stack.size() - 1) total stack.get(stack.size() - 1) stack.get stack stack.size() - 1 stack.size() stack.size stack 1 System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {
	public static final String plus = "+";
	public static final String minus = "-";
	public static final String kake = "*";
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		String strInt = null;
		int intStr = 0;
		int numInt1 = 0;
		int numInt2 = 0;
		int total = 0;
		List<Integer> stack = new ArrayList<Integer>(100);
		while(sc.hasNext()){
			strInt = sc.next();
			if(strInt.equals(plus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 + numInt2;
				stack.add(total);
			}else if(strInt.equals(minus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 - numInt2;
				stack.add(total);
			}else if(strInt.equalsIgnoreCase(kake)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 * numInt2;
				stack.add(total);
			}else{
				intStr = Integer.parseInt(strInt);
				stack.add(intStr);
			}
		}
		total = stack.get(stack.size() - 1);
		System.out.println(total);
	}
} public class Main {
	public static final String plus = "+";
	public static final String minus = "-";
	public static final String kake = "*";
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		String strInt = null;
		int intStr = 0;
		int numInt1 = 0;
		int numInt2 = 0;
		int total = 0;
		List<Integer> stack = new ArrayList<Integer>(100);
		while(sc.hasNext()){
			strInt = sc.next();
			if(strInt.equals(plus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 + numInt2;
				stack.add(total);
			}else if(strInt.equals(minus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 - numInt2;
				stack.add(total);
			}else if(strInt.equalsIgnoreCase(kake)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 * numInt2;
				stack.add(total);
			}else{
				intStr = Integer.parseInt(strInt);
				stack.add(intStr);
			}
		}
		total = stack.get(stack.size() - 1);
		System.out.println(total);
	}
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static final String plus = "+";
	public static final String minus = "-";
	public static final String kake = "*";
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		String strInt = null;
		int intStr = 0;
		int numInt1 = 0;
		int numInt2 = 0;
		int total = 0;
		List<Integer> stack = new ArrayList<Integer>(100);
		while(sc.hasNext()){
			strInt = sc.next();
			if(strInt.equals(plus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 + numInt2;
				stack.add(total);
			}else if(strInt.equals(minus)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 - numInt2;
				stack.add(total);
			}else if(strInt.equalsIgnoreCase(kake)){
				numInt2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				numInt1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				total = numInt1 * numInt2;
				stack.add(total);
			}else{
				intStr = Integer.parseInt(strInt);
				stack.add(intStr);
			}
		}
		total = stack.get(stack.size() - 1);
		System.out.println(total);
	}
}