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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Deque<Integer> deq = new ArrayDeque<Integer>();
        String str = "";
        int a = 0, b = 0;
        while(sc.hasNext()){
        	str = sc.next();
        	if(str.equals("+")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a + b);
        	}else if(str.equals("-")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b - a);
        	}else if(str.equals("*")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a * b);
        	}else if(str.equals("/")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b / a);
        	}else{
        		deq.addLast(Integer.parseInt(str));
        	}
        }
        System.out.println(deq.peekLast());
    }
} import java.util.Scanner; Scanner java.util import java.util.Deque; Deque java.util import java.util.ArrayDeque; ArrayDeque java.util public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Deque<Integer> deq = new ArrayDeque<Integer>();
        String str = "";
        int a = 0, b = 0;
        while(sc.hasNext()){
        	str = sc.next();
        	if(str.equals("+")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a + b);
        	}else if(str.equals("-")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b - a);
        	}else if(str.equals("*")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a * b);
        	}else if(str.equals("/")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b / a);
        	}else{
        		deq.addLast(Integer.parseInt(str));
        	}
        }
        System.out.println(deq.peekLast());
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Deque<Integer> deq = new ArrayDeque<Integer>();
        String str = "";
        int a = 0, b = 0;
        while(sc.hasNext()){
        	str = sc.next();
        	if(str.equals("+")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a + b);
        	}else if(str.equals("-")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b - a);
        	}else if(str.equals("*")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a * b);
        	}else if(str.equals("/")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b / a);
        	}else{
        		deq.addLast(Integer.parseInt(str));
        	}
        }
        System.out.println(deq.peekLast());
    } main {
        Scanner sc = new Scanner(System.in);
        Deque<Integer> deq = new ArrayDeque<Integer>();
        String str = "";
        int a = 0, b = 0;
        while(sc.hasNext()){
        	str = sc.next();
        	if(str.equals("+")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a + b);
        	}else if(str.equals("-")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b - a);
        	}else if(str.equals("*")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a * b);
        	}else if(str.equals("/")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b / a);
        	}else{
        		deq.addLast(Integer.parseInt(str));
        	}
        }
        System.out.println(deq.peekLast());
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Deque<Integer> deq = new ArrayDeque<Integer>(); deq new ArrayDeque<Integer>() String str = ""; str "" int a = 0 a 0 b = 0; b 0 while(sc.hasNext()){
        	str = sc.next();
        	if(str.equals("+")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a + b);
        	}else if(str.equals("-")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b - a);
        	}else if(str.equals("*")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a * b);
        	}else if(str.equals("/")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b / a);
        	}else{
        		deq.addLast(Integer.parseInt(str));
        	}
        } sc.hasNext() sc.hasNext sc {
        	str = sc.next();
        	if(str.equals("+")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a + b);
        	}else if(str.equals("-")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b - a);
        	}else if(str.equals("*")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a * b);
        	}else if(str.equals("/")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b / a);
        	}else{
        		deq.addLast(Integer.parseInt(str));
        	}
        } str = sc.next() str sc.next() sc.next sc if(str.equals("+")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a + b);
        	}else if(str.equals("-")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b - a);
        	}else if(str.equals("*")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a * b);
        	}else if(str.equals("/")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b / a);
        	}else{
        		deq.addLast(Integer.parseInt(str));
        	} str.equals("+") str.equals str "+" {
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a + b);
        	} a = deq.pollLast() a deq.pollLast() deq.pollLast deq b = deq.pollLast() b deq.pollLast() deq.pollLast deq deq.addLast(a + b) deq.addLast deq a + b a b if(str.equals("-")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b - a);
        	}else if(str.equals("*")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a * b);
        	}else if(str.equals("/")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b / a);
        	}else{
        		deq.addLast(Integer.parseInt(str));
        	} str.equals("-") str.equals str "-" {
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b - a);
        	} a = deq.pollLast() a deq.pollLast() deq.pollLast deq b = deq.pollLast() b deq.pollLast() deq.pollLast deq deq.addLast(b - a) deq.addLast deq b - a b a if(str.equals("*")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a * b);
        	}else if(str.equals("/")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b / a);
        	}else{
        		deq.addLast(Integer.parseInt(str));
        	} str.equals("*") str.equals str "*" {
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a * b);
        	} a = deq.pollLast() a deq.pollLast() deq.pollLast deq b = deq.pollLast() b deq.pollLast() deq.pollLast deq deq.addLast(a * b) deq.addLast deq a * b a b if(str.equals("/")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b / a);
        	}else{
        		deq.addLast(Integer.parseInt(str));
        	} str.equals("/") str.equals str "/" {
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b / a);
        	} a = deq.pollLast() a deq.pollLast() deq.pollLast deq b = deq.pollLast() b deq.pollLast() deq.pollLast deq deq.addLast(b / a) deq.addLast deq b / a b a {
        		deq.addLast(Integer.parseInt(str));
        	} deq.addLast(Integer.parseInt(str)) deq.addLast deq Integer.parseInt(str) Integer.parseInt Integer str System.out.println(deq.peekLast()) System.out.println System.out System System.out deq.peekLast() deq.peekLast deq String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Deque<Integer> deq = new ArrayDeque<Integer>();
        String str = "";
        int a = 0, b = 0;
        while(sc.hasNext()){
        	str = sc.next();
        	if(str.equals("+")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a + b);
        	}else if(str.equals("-")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b - a);
        	}else if(str.equals("*")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a * b);
        	}else if(str.equals("/")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b / a);
        	}else{
        		deq.addLast(Integer.parseInt(str));
        	}
        }
        System.out.println(deq.peekLast());
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Deque<Integer> deq = new ArrayDeque<Integer>();
        String str = "";
        int a = 0, b = 0;
        while(sc.hasNext()){
        	str = sc.next();
        	if(str.equals("+")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a + b);
        	}else if(str.equals("-")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b - a);
        	}else if(str.equals("*")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a * b);
        	}else if(str.equals("/")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b / a);
        	}else{
        		deq.addLast(Integer.parseInt(str));
        	}
        }
        System.out.println(deq.peekLast());
    }
} Main
import java.util.Scanner;
import java.util.Deque;
import java.util.ArrayDeque;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Deque<Integer> deq = new ArrayDeque<Integer>();
        String str = "";
        int a = 0, b = 0;
        while(sc.hasNext()){
        	str = sc.next();
        	if(str.equals("+")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a + b);
        	}else if(str.equals("-")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b - a);
        	}else if(str.equals("*")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(a * b);
        	}else if(str.equals("/")){
        		a = deq.pollLast();
        		b = deq.pollLast();
        		deq.addLast(b / a);
        	}else{
        		deq.addLast(Integer.parseInt(str));
        	}
        }
        System.out.println(deq.peekLast());
    }
}
