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

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner scanner=new Scanner(System.in);
        Deque<Integer> deque=new ArrayDeque<>();
        int count=0;
        while(scanner.hasNext()){
            String input=scanner.next();
            //count++;
            //System.out.println(String.format("%d:%s",count,input));
            if(input.charAt(0)=='*'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x*y);
            }else if(input.charAt(0)=='+'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x+y);

            }else if(input.charAt(0)=='-'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(y-x);

            }else{
                int i=Integer.parseInt(input);
                deque.addFirst(i);
            }
        }
        //System.out.println(deque);
        System.out.println(deque.removeFirst());
    }
}
 import java.util.ArrayDeque; ArrayDeque java.util import java.util.Deque; Deque java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner scanner=new Scanner(System.in);
        Deque<Integer> deque=new ArrayDeque<>();
        int count=0;
        while(scanner.hasNext()){
            String input=scanner.next();
            //count++;
            //System.out.println(String.format("%d:%s",count,input));
            if(input.charAt(0)=='*'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x*y);
            }else if(input.charAt(0)=='+'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x+y);

            }else if(input.charAt(0)=='-'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(y-x);

            }else{
                int i=Integer.parseInt(input);
                deque.addFirst(i);
            }
        }
        //System.out.println(deque);
        System.out.println(deque.removeFirst());
    }
} Main public static void main(String[] args) {
	// write your code here
        Scanner scanner=new Scanner(System.in);
        Deque<Integer> deque=new ArrayDeque<>();
        int count=0;
        while(scanner.hasNext()){
            String input=scanner.next();
            //count++;
            //System.out.println(String.format("%d:%s",count,input));
            if(input.charAt(0)=='*'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x*y);
            }else if(input.charAt(0)=='+'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x+y);

            }else if(input.charAt(0)=='-'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(y-x);

            }else{
                int i=Integer.parseInt(input);
                deque.addFirst(i);
            }
        }
        //System.out.println(deque);
        System.out.println(deque.removeFirst());
    } main {
	// write your code here
        Scanner scanner=new Scanner(System.in);
        Deque<Integer> deque=new ArrayDeque<>();
        int count=0;
        while(scanner.hasNext()){
            String input=scanner.next();
            //count++;
            //System.out.println(String.format("%d:%s",count,input));
            if(input.charAt(0)=='*'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x*y);
            }else if(input.charAt(0)=='+'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x+y);

            }else if(input.charAt(0)=='-'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(y-x);

            }else{
                int i=Integer.parseInt(input);
                deque.addFirst(i);
            }
        }
        //System.out.println(deque);
        System.out.println(deque.removeFirst());
    } Scanner scanner=new Scanner(System.in); scanner new Scanner(System.in) Deque<Integer> deque=new ArrayDeque<>(); deque new ArrayDeque<>() int count=0; count 0 while(scanner.hasNext()){
            String input=scanner.next();
            //count++;
            //System.out.println(String.format("%d:%s",count,input));
            if(input.charAt(0)=='*'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x*y);
            }else if(input.charAt(0)=='+'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x+y);

            }else if(input.charAt(0)=='-'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(y-x);

            }else{
                int i=Integer.parseInt(input);
                deque.addFirst(i);
            }
        } scanner.hasNext() scanner.hasNext scanner {
            String input=scanner.next();
            //count++;
            //System.out.println(String.format("%d:%s",count,input));
            if(input.charAt(0)=='*'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x*y);
            }else if(input.charAt(0)=='+'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x+y);

            }else if(input.charAt(0)=='-'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(y-x);

            }else{
                int i=Integer.parseInt(input);
                deque.addFirst(i);
            }
        } String input=scanner.next(); input scanner.next() scanner.next scanner if(input.charAt(0)=='*'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x*y);
            }else if(input.charAt(0)=='+'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x+y);

            }else if(input.charAt(0)=='-'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(y-x);

            }else{
                int i=Integer.parseInt(input);
                deque.addFirst(i);
            } input.charAt(0)=='*' input.charAt(0) input.charAt input 0 '*' {
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x*y);
            } int x=deque.removeFirst(); x deque.removeFirst() deque.removeFirst deque int y=deque.removeFirst(); y deque.removeFirst() deque.removeFirst deque deque.addFirst(x*y) deque.addFirst deque x*y x y if(input.charAt(0)=='+'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x+y);

            }else if(input.charAt(0)=='-'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(y-x);

            }else{
                int i=Integer.parseInt(input);
                deque.addFirst(i);
            } input.charAt(0)=='+' input.charAt(0) input.charAt input 0 '+' {
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x+y);

            } int x=deque.removeFirst(); x deque.removeFirst() deque.removeFirst deque int y=deque.removeFirst(); y deque.removeFirst() deque.removeFirst deque deque.addFirst(x+y) deque.addFirst deque x+y x y if(input.charAt(0)=='-'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(y-x);

            }else{
                int i=Integer.parseInt(input);
                deque.addFirst(i);
            } input.charAt(0)=='-' input.charAt(0) input.charAt input 0 '-' {
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(y-x);

            } int x=deque.removeFirst(); x deque.removeFirst() deque.removeFirst deque int y=deque.removeFirst(); y deque.removeFirst() deque.removeFirst deque deque.addFirst(y-x) deque.addFirst deque y-x y x {
                int i=Integer.parseInt(input);
                deque.addFirst(i);
            } int i=Integer.parseInt(input); i Integer.parseInt(input) Integer.parseInt Integer input deque.addFirst(i) deque.addFirst deque i System.out.println(deque.removeFirst()) System.out.println System.out System System.out deque.removeFirst() deque.removeFirst deque String[] args args public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner scanner=new Scanner(System.in);
        Deque<Integer> deque=new ArrayDeque<>();
        int count=0;
        while(scanner.hasNext()){
            String input=scanner.next();
            //count++;
            //System.out.println(String.format("%d:%s",count,input));
            if(input.charAt(0)=='*'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x*y);
            }else if(input.charAt(0)=='+'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x+y);

            }else if(input.charAt(0)=='-'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(y-x);

            }else{
                int i=Integer.parseInt(input);
                deque.addFirst(i);
            }
        }
        //System.out.println(deque);
        System.out.println(deque.removeFirst());
    }
} public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner scanner=new Scanner(System.in);
        Deque<Integer> deque=new ArrayDeque<>();
        int count=0;
        while(scanner.hasNext()){
            String input=scanner.next();
            //count++;
            //System.out.println(String.format("%d:%s",count,input));
            if(input.charAt(0)=='*'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x*y);
            }else if(input.charAt(0)=='+'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x+y);

            }else if(input.charAt(0)=='-'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(y-x);

            }else{
                int i=Integer.parseInt(input);
                deque.addFirst(i);
            }
        }
        //System.out.println(deque);
        System.out.println(deque.removeFirst());
    }
} Main

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

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner scanner=new Scanner(System.in);
        Deque<Integer> deque=new ArrayDeque<>();
        int count=0;
        while(scanner.hasNext()){
            String input=scanner.next();
            //count++;
            //System.out.println(String.format("%d:%s",count,input));
            if(input.charAt(0)=='*'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x*y);
            }else if(input.charAt(0)=='+'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(x+y);

            }else if(input.charAt(0)=='-'){
                int x=deque.removeFirst();
                int y=deque.removeFirst();
                deque.addFirst(y-x);

            }else{
                int i=Integer.parseInt(input);
                deque.addFirst(i);
            }
        }
        //System.out.println(deque);
        System.out.println(deque.removeFirst());
    }
}

