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());
    }
}


/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz