import java.util.Scanner;
import java.util.Stack;
import java.io.*;

class Main {
    static Stack<Integer> ans = new Stack<>();
    static int a;
    static int b;

    private static int compute(String s){
        if (s.charAt(0) == '+') return b + a;
        else if ( s.charAt(0) == '-') return b - a;

        return b * a;
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        sc = new Scanner(s);

        while(sc.hasNext()){
            if(sc.hasNextInt())
                ans.push(sc.nextInt());
            else{
                a = ans.pop();
                b = ans.pop();
                ans.push(compute(sc.next()));
            }
        }
        System.out.println(ans.pop());
    }
}
 import java.util.Scanner; Scanner java.util import java.util.Stack; Stack java.util import java.io.*; io.* java class Main {
    static Stack<Integer> ans = new Stack<>();
    static int a;
    static int b;

    private static int compute(String s){
        if (s.charAt(0) == '+') return b + a;
        else if ( s.charAt(0) == '-') return b - a;

        return b * a;
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        sc = new Scanner(s);

        while(sc.hasNext()){
            if(sc.hasNextInt())
                ans.push(sc.nextInt());
            else{
                a = ans.pop();
                b = ans.pop();
                ans.push(compute(sc.next()));
            }
        }
        System.out.println(ans.pop());
    }
} Main static Stack<Integer> ans = new Stack<>(); ans new Stack<>() static int a; a static int b; b private static int compute(String s){
        if (s.charAt(0) == '+') return b + a;
        else if ( s.charAt(0) == '-') return b - a;

        return b * a;
    } compute {
        if (s.charAt(0) == '+') return b + a;
        else if ( s.charAt(0) == '-') return b - a;

        return b * a;
    } if (s.charAt(0) == '+') return b + a;
        else if ( s.charAt(0) == '-') return b - a; s.charAt(0) == '+' s.charAt(0) s.charAt s 0 '+' return b + a; b + a b a if ( s.charAt(0) == '-') return b - a; s.charAt(0) == '-' s.charAt(0) s.charAt s 0 '-' return b - a; b - a b a return b * a; b * a b a String s s public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        sc = new Scanner(s);

        while(sc.hasNext()){
            if(sc.hasNextInt())
                ans.push(sc.nextInt());
            else{
                a = ans.pop();
                b = ans.pop();
                ans.push(compute(sc.next()));
            }
        }
        System.out.println(ans.pop());
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        sc = new Scanner(s);

        while(sc.hasNext()){
            if(sc.hasNextInt())
                ans.push(sc.nextInt());
            else{
                a = ans.pop();
                b = ans.pop();
                ans.push(compute(sc.next()));
            }
        }
        System.out.println(ans.pop());
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.nextLine(); s sc.nextLine() sc.nextLine sc sc = new Scanner(s) sc new Scanner(s) while(sc.hasNext()){
            if(sc.hasNextInt())
                ans.push(sc.nextInt());
            else{
                a = ans.pop();
                b = ans.pop();
                ans.push(compute(sc.next()));
            }
        } sc.hasNext() sc.hasNext sc {
            if(sc.hasNextInt())
                ans.push(sc.nextInt());
            else{
                a = ans.pop();
                b = ans.pop();
                ans.push(compute(sc.next()));
            }
        } if(sc.hasNextInt())
                ans.push(sc.nextInt());
            else{
                a = ans.pop();
                b = ans.pop();
                ans.push(compute(sc.next()));
            } sc.hasNextInt() sc.hasNextInt sc ans.push(sc.nextInt()) ans.push ans sc.nextInt() sc.nextInt sc {
                a = ans.pop();
                b = ans.pop();
                ans.push(compute(sc.next()));
            } a = ans.pop() a ans.pop() ans.pop ans b = ans.pop() b ans.pop() ans.pop ans ans.push(compute(sc.next())) ans.push ans compute(sc.next()) compute sc.next() sc.next sc System.out.println(ans.pop()) System.out.println System.out System System.out ans.pop() ans.pop ans String[] args args
import java.util.Scanner;
import java.util.Stack;
import java.io.*;

class Main {
    static Stack<Integer> ans = new Stack<>();
    static int a;
    static int b;

    private static int compute(String s){
        if (s.charAt(0) == '+') return b + a;
        else if ( s.charAt(0) == '-') return b - a;

        return b * a;
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        sc = new Scanner(s);

        while(sc.hasNext()){
            if(sc.hasNextInt())
                ans.push(sc.nextInt());
            else{
                a = ans.pop();
                b = ans.pop();
                ans.push(compute(sc.next()));
            }
        }
        System.out.println(ans.pop());
    }
}

