import java.util.Scanner;

import java.util.Stack;

public class Main {

   public static void main(String[] args) {
        Stack<Integer>stack = new Stack<>();
        
        Scanner scan = new Scanner(System.in);
 
        String input = scan.nextLine();
        String[] AK = input.split(" ",0);
        scan.close();
        int kfc = AK.length;   
        for(int i = 0; i < kfc; ++i) {
            
            if (AK[i].equals("+")) {
               int x = stack.pop(),y = stack.pop();
                stack.push(y + x);
            }
            else if (AK[i].equals("-")) {
                int x = stack.pop(),y = stack.pop();
                
                stack.push(y - x);
            }
            else if (AK[i].equals("*")) {
                int x = stack.pop(),y = stack.pop();
                int B = x*y;
                int C = B;
                stack.push(C);
            }
            else {
               stack.push(Integer.parseInt(AK[i]));
            }
        }
        System.out.println(stack.firstElement());
    }
 } import java.util.Scanner; Scanner java.util import java.util.Stack; Stack java.util public class Main {

   public static void main(String[] args) {
        Stack<Integer>stack = new Stack<>();
        
        Scanner scan = new Scanner(System.in);
 
        String input = scan.nextLine();
        String[] AK = input.split(" ",0);
        scan.close();
        int kfc = AK.length;   
        for(int i = 0; i < kfc; ++i) {
            
            if (AK[i].equals("+")) {
               int x = stack.pop(),y = stack.pop();
                stack.push(y + x);
            }
            else if (AK[i].equals("-")) {
                int x = stack.pop(),y = stack.pop();
                
                stack.push(y - x);
            }
            else if (AK[i].equals("*")) {
                int x = stack.pop(),y = stack.pop();
                int B = x*y;
                int C = B;
                stack.push(C);
            }
            else {
               stack.push(Integer.parseInt(AK[i]));
            }
        }
        System.out.println(stack.firstElement());
    }
 } Main public static void main(String[] args) {
        Stack<Integer>stack = new Stack<>();
        
        Scanner scan = new Scanner(System.in);
 
        String input = scan.nextLine();
        String[] AK = input.split(" ",0);
        scan.close();
        int kfc = AK.length;   
        for(int i = 0; i < kfc; ++i) {
            
            if (AK[i].equals("+")) {
               int x = stack.pop(),y = stack.pop();
                stack.push(y + x);
            }
            else if (AK[i].equals("-")) {
                int x = stack.pop(),y = stack.pop();
                
                stack.push(y - x);
            }
            else if (AK[i].equals("*")) {
                int x = stack.pop(),y = stack.pop();
                int B = x*y;
                int C = B;
                stack.push(C);
            }
            else {
               stack.push(Integer.parseInt(AK[i]));
            }
        }
        System.out.println(stack.firstElement());
    } main {
        Stack<Integer>stack = new Stack<>();
        
        Scanner scan = new Scanner(System.in);
 
        String input = scan.nextLine();
        String[] AK = input.split(" ",0);
        scan.close();
        int kfc = AK.length;   
        for(int i = 0; i < kfc; ++i) {
            
            if (AK[i].equals("+")) {
               int x = stack.pop(),y = stack.pop();
                stack.push(y + x);
            }
            else if (AK[i].equals("-")) {
                int x = stack.pop(),y = stack.pop();
                
                stack.push(y - x);
            }
            else if (AK[i].equals("*")) {
                int x = stack.pop(),y = stack.pop();
                int B = x*y;
                int C = B;
                stack.push(C);
            }
            else {
               stack.push(Integer.parseInt(AK[i]));
            }
        }
        System.out.println(stack.firstElement());
    } Stack<Integer>stack = new Stack<>(); stack new Stack<>() Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String input = scan.nextLine(); input scan.nextLine() scan.nextLine scan String[] AK = input.split(" ",0); AK input.split(" ",0) input.split input " " 0 scan.close() scan.close scan int kfc = AK.length; kfc AK.length AK AK.length for(int i = 0; i < kfc; ++i) {
            
            if (AK[i].equals("+")) {
               int x = stack.pop(),y = stack.pop();
                stack.push(y + x);
            }
            else if (AK[i].equals("-")) {
                int x = stack.pop(),y = stack.pop();
                
                stack.push(y - x);
            }
            else if (AK[i].equals("*")) {
                int x = stack.pop(),y = stack.pop();
                int B = x*y;
                int C = B;
                stack.push(C);
            }
            else {
               stack.push(Integer.parseInt(AK[i]));
            }
        } int i = 0; int i = 0; i 0 i < kfc i kfc ++i ++i i {
            
            if (AK[i].equals("+")) {
               int x = stack.pop(),y = stack.pop();
                stack.push(y + x);
            }
            else if (AK[i].equals("-")) {
                int x = stack.pop(),y = stack.pop();
                
                stack.push(y - x);
            }
            else if (AK[i].equals("*")) {
                int x = stack.pop(),y = stack.pop();
                int B = x*y;
                int C = B;
                stack.push(C);
            }
            else {
               stack.push(Integer.parseInt(AK[i]));
            }
        } {
            
            if (AK[i].equals("+")) {
               int x = stack.pop(),y = stack.pop();
                stack.push(y + x);
            }
            else if (AK[i].equals("-")) {
                int x = stack.pop(),y = stack.pop();
                
                stack.push(y - x);
            }
            else if (AK[i].equals("*")) {
                int x = stack.pop(),y = stack.pop();
                int B = x*y;
                int C = B;
                stack.push(C);
            }
            else {
               stack.push(Integer.parseInt(AK[i]));
            }
        } if (AK[i].equals("+")) {
               int x = stack.pop(),y = stack.pop();
                stack.push(y + x);
            }
            else if (AK[i].equals("-")) {
                int x = stack.pop(),y = stack.pop();
                
                stack.push(y - x);
            }
            else if (AK[i].equals("*")) {
                int x = stack.pop(),y = stack.pop();
                int B = x*y;
                int C = B;
                stack.push(C);
            }
            else {
               stack.push(Integer.parseInt(AK[i]));
            } AK[i].equals("+") AK[i].equals AK[i] AK i "+" {
               int x = stack.pop(),y = stack.pop();
                stack.push(y + x);
            } int x = stack.pop() x stack.pop() stack.pop stack y = stack.pop(); y stack.pop() stack.pop stack stack.push(y + x) stack.push stack y + x y x if (AK[i].equals("-")) {
                int x = stack.pop(),y = stack.pop();
                
                stack.push(y - x);
            }
            else if (AK[i].equals("*")) {
                int x = stack.pop(),y = stack.pop();
                int B = x*y;
                int C = B;
                stack.push(C);
            }
            else {
               stack.push(Integer.parseInt(AK[i]));
            } AK[i].equals("-") AK[i].equals AK[i] AK i "-" {
                int x = stack.pop(),y = stack.pop();
                
                stack.push(y - x);
            } int x = stack.pop() x stack.pop() stack.pop stack y = stack.pop(); y stack.pop() stack.pop stack stack.push(y - x) stack.push stack y - x y x if (AK[i].equals("*")) {
                int x = stack.pop(),y = stack.pop();
                int B = x*y;
                int C = B;
                stack.push(C);
            }
            else {
               stack.push(Integer.parseInt(AK[i]));
            } AK[i].equals("*") AK[i].equals AK[i] AK i "*" {
                int x = stack.pop(),y = stack.pop();
                int B = x*y;
                int C = B;
                stack.push(C);
            } int x = stack.pop() x stack.pop() stack.pop stack y = stack.pop(); y stack.pop() stack.pop stack int B = x*y; B x*y x y int C = B; C B stack.push(C) stack.push stack C {
               stack.push(Integer.parseInt(AK[i]));
            } stack.push(Integer.parseInt(AK[i])) stack.push stack Integer.parseInt(AK[i]) Integer.parseInt Integer AK[i] AK i System.out.println(stack.firstElement()) System.out.println System.out System System.out stack.firstElement() stack.firstElement stack String[] args args public class Main {

   public static void main(String[] args) {
        Stack<Integer>stack = new Stack<>();
        
        Scanner scan = new Scanner(System.in);
 
        String input = scan.nextLine();
        String[] AK = input.split(" ",0);
        scan.close();
        int kfc = AK.length;   
        for(int i = 0; i < kfc; ++i) {
            
            if (AK[i].equals("+")) {
               int x = stack.pop(),y = stack.pop();
                stack.push(y + x);
            }
            else if (AK[i].equals("-")) {
                int x = stack.pop(),y = stack.pop();
                
                stack.push(y - x);
            }
            else if (AK[i].equals("*")) {
                int x = stack.pop(),y = stack.pop();
                int B = x*y;
                int C = B;
                stack.push(C);
            }
            else {
               stack.push(Integer.parseInt(AK[i]));
            }
        }
        System.out.println(stack.firstElement());
    }
 } public class Main {

   public static void main(String[] args) {
        Stack<Integer>stack = new Stack<>();
        
        Scanner scan = new Scanner(System.in);
 
        String input = scan.nextLine();
        String[] AK = input.split(" ",0);
        scan.close();
        int kfc = AK.length;   
        for(int i = 0; i < kfc; ++i) {
            
            if (AK[i].equals("+")) {
               int x = stack.pop(),y = stack.pop();
                stack.push(y + x);
            }
            else if (AK[i].equals("-")) {
                int x = stack.pop(),y = stack.pop();
                
                stack.push(y - x);
            }
            else if (AK[i].equals("*")) {
                int x = stack.pop(),y = stack.pop();
                int B = x*y;
                int C = B;
                stack.push(C);
            }
            else {
               stack.push(Integer.parseInt(AK[i]));
            }
        }
        System.out.println(stack.firstElement());
    }
 } Main
import java.util.Scanner;

import java.util.Stack;

public class Main {

   public static void main(String[] args) {
        Stack<Integer>stack = new Stack<>();
        
        Scanner scan = new Scanner(System.in);
 
        String input = scan.nextLine();
        String[] AK = input.split(" ",0);
        scan.close();
        int kfc = AK.length;   
        for(int i = 0; i < kfc; ++i) {
            
            if (AK[i].equals("+")) {
               int x = stack.pop(),y = stack.pop();
                stack.push(y + x);
            }
            else if (AK[i].equals("-")) {
                int x = stack.pop(),y = stack.pop();
                
                stack.push(y - x);
            }
            else if (AK[i].equals("*")) {
                int x = stack.pop(),y = stack.pop();
                int B = x*y;
                int C = B;
                stack.push(C);
            }
            else {
               stack.push(Integer.parseInt(AK[i]));
            }
        }
        System.out.println(stack.firstElement());
    }
 }
