import java.io.*;
class Sta{
    int[] s;
    int top;
    Sta(){
        s=new int[1000];
        top=0;
    }
    void push(int x){
        top++;
        s[top]=x;
    }
    int pop(){
        top--;
        return s[top+1];
    }
}
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader din=new BufferedReader(new InputStreamReader(System.in));
        String line=din.readLine();
        String[] tokens=line.split(" ");
        Sta stack=new Sta();
        for(int i=0;i<tokens.length;i++){
            String x=tokens[i];
            if(x.equals("+")){
                stack.push(stack.pop()+stack.pop());
            }else if(x.equals("-")){
                stack.push(-stack.pop()+stack.pop());
            }else if(x.equals("*")){
                stack.push(stack.pop()*stack.pop());
            }else{
                int t=Integer.parseInt(x);
                stack.push(t);
            }
        }
        System.out.println(stack.pop());
    }
} import java.io.*; io.* java class Sta{
    int[] s;
    int top;
    Sta(){
        s=new int[1000];
        top=0;
    }
    void push(int x){
        top++;
        s[top]=x;
    }
    int pop(){
        top--;
        return s[top+1];
    }
} Sta int[] s; s int top; top Sta(){
        s=new int[1000];
        top=0;
    } Sta {
        s=new int[1000];
        top=0;
    } s=new int[1000] s new int[1000] 1000 top=0 top 0 void push(int x){
        top++;
        s[top]=x;
    } push {
        top++;
        s[top]=x;
    } top++ top s[top]=x s[top] s top x int x x int pop(){
        top--;
        return s[top+1];
    } pop {
        top--;
        return s[top+1];
    } top-- top return s[top+1]; s[top+1] s top+1 top 1 public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader din=new BufferedReader(new InputStreamReader(System.in));
        String line=din.readLine();
        String[] tokens=line.split(" ");
        Sta stack=new Sta();
        for(int i=0;i<tokens.length;i++){
            String x=tokens[i];
            if(x.equals("+")){
                stack.push(stack.pop()+stack.pop());
            }else if(x.equals("-")){
                stack.push(-stack.pop()+stack.pop());
            }else if(x.equals("*")){
                stack.push(stack.pop()*stack.pop());
            }else{
                int t=Integer.parseInt(x);
                stack.push(t);
            }
        }
        System.out.println(stack.pop());
    }
} Main public static void main(String[] args) throws IOException{
        BufferedReader din=new BufferedReader(new InputStreamReader(System.in));
        String line=din.readLine();
        String[] tokens=line.split(" ");
        Sta stack=new Sta();
        for(int i=0;i<tokens.length;i++){
            String x=tokens[i];
            if(x.equals("+")){
                stack.push(stack.pop()+stack.pop());
            }else if(x.equals("-")){
                stack.push(-stack.pop()+stack.pop());
            }else if(x.equals("*")){
                stack.push(stack.pop()*stack.pop());
            }else{
                int t=Integer.parseInt(x);
                stack.push(t);
            }
        }
        System.out.println(stack.pop());
    } main {
        BufferedReader din=new BufferedReader(new InputStreamReader(System.in));
        String line=din.readLine();
        String[] tokens=line.split(" ");
        Sta stack=new Sta();
        for(int i=0;i<tokens.length;i++){
            String x=tokens[i];
            if(x.equals("+")){
                stack.push(stack.pop()+stack.pop());
            }else if(x.equals("-")){
                stack.push(-stack.pop()+stack.pop());
            }else if(x.equals("*")){
                stack.push(stack.pop()*stack.pop());
            }else{
                int t=Integer.parseInt(x);
                stack.push(t);
            }
        }
        System.out.println(stack.pop());
    } BufferedReader din=new BufferedReader(new InputStreamReader(System.in)); din new BufferedReader(new InputStreamReader(System.in)) String line=din.readLine(); line din.readLine() din.readLine din String[] tokens=line.split(" "); tokens line.split(" ") line.split line " " Sta stack=new Sta(); stack new Sta() for(int i=0;i<tokens.length;i++){
            String x=tokens[i];
            if(x.equals("+")){
                stack.push(stack.pop()+stack.pop());
            }else if(x.equals("-")){
                stack.push(-stack.pop()+stack.pop());
            }else if(x.equals("*")){
                stack.push(stack.pop()*stack.pop());
            }else{
                int t=Integer.parseInt(x);
                stack.push(t);
            }
        } int i=0; int i=0; i 0 i<tokens.length i tokens.length tokens tokens.length i++ i++ i {
            String x=tokens[i];
            if(x.equals("+")){
                stack.push(stack.pop()+stack.pop());
            }else if(x.equals("-")){
                stack.push(-stack.pop()+stack.pop());
            }else if(x.equals("*")){
                stack.push(stack.pop()*stack.pop());
            }else{
                int t=Integer.parseInt(x);
                stack.push(t);
            }
        } {
            String x=tokens[i];
            if(x.equals("+")){
                stack.push(stack.pop()+stack.pop());
            }else if(x.equals("-")){
                stack.push(-stack.pop()+stack.pop());
            }else if(x.equals("*")){
                stack.push(stack.pop()*stack.pop());
            }else{
                int t=Integer.parseInt(x);
                stack.push(t);
            }
        } String x=tokens[i]; x tokens[i] tokens i if(x.equals("+")){
                stack.push(stack.pop()+stack.pop());
            }else if(x.equals("-")){
                stack.push(-stack.pop()+stack.pop());
            }else if(x.equals("*")){
                stack.push(stack.pop()*stack.pop());
            }else{
                int t=Integer.parseInt(x);
                stack.push(t);
            } x.equals("+") x.equals x "+" {
                stack.push(stack.pop()+stack.pop());
            } stack.push(stack.pop()+stack.pop()) stack.push stack stack.pop()+stack.pop() stack.pop() stack.pop stack stack.pop() stack.pop stack if(x.equals("-")){
                stack.push(-stack.pop()+stack.pop());
            }else if(x.equals("*")){
                stack.push(stack.pop()*stack.pop());
            }else{
                int t=Integer.parseInt(x);
                stack.push(t);
            } x.equals("-") x.equals x "-" {
                stack.push(-stack.pop()+stack.pop());
            } stack.push(-stack.pop()+stack.pop()) stack.push stack -stack.pop()+stack.pop() -stack.pop() stack.pop() stack.pop stack stack.pop() stack.pop stack if(x.equals("*")){
                stack.push(stack.pop()*stack.pop());
            }else{
                int t=Integer.parseInt(x);
                stack.push(t);
            } x.equals("*") x.equals x "*" {
                stack.push(stack.pop()*stack.pop());
            } stack.push(stack.pop()*stack.pop()) stack.push stack stack.pop()*stack.pop() stack.pop() stack.pop stack stack.pop() stack.pop stack {
                int t=Integer.parseInt(x);
                stack.push(t);
            } int t=Integer.parseInt(x); t Integer.parseInt(x) Integer.parseInt Integer x stack.push(t) stack.push stack t System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader din=new BufferedReader(new InputStreamReader(System.in));
        String line=din.readLine();
        String[] tokens=line.split(" ");
        Sta stack=new Sta();
        for(int i=0;i<tokens.length;i++){
            String x=tokens[i];
            if(x.equals("+")){
                stack.push(stack.pop()+stack.pop());
            }else if(x.equals("-")){
                stack.push(-stack.pop()+stack.pop());
            }else if(x.equals("*")){
                stack.push(stack.pop()*stack.pop());
            }else{
                int t=Integer.parseInt(x);
                stack.push(t);
            }
        }
        System.out.println(stack.pop());
    }
} public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader din=new BufferedReader(new InputStreamReader(System.in));
        String line=din.readLine();
        String[] tokens=line.split(" ");
        Sta stack=new Sta();
        for(int i=0;i<tokens.length;i++){
            String x=tokens[i];
            if(x.equals("+")){
                stack.push(stack.pop()+stack.pop());
            }else if(x.equals("-")){
                stack.push(-stack.pop()+stack.pop());
            }else if(x.equals("*")){
                stack.push(stack.pop()*stack.pop());
            }else{
                int t=Integer.parseInt(x);
                stack.push(t);
            }
        }
        System.out.println(stack.pop());
    }
} Main
import java.io.*;
class Sta{
    int[] s;
    int top;
    Sta(){
        s=new int[1000];
        top=0;
    }
    void push(int x){
        top++;
        s[top]=x;
    }
    int pop(){
        top--;
        return s[top+1];
    }
}
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader din=new BufferedReader(new InputStreamReader(System.in));
        String line=din.readLine();
        String[] tokens=line.split(" ");
        Sta stack=new Sta();
        for(int i=0;i<tokens.length;i++){
            String x=tokens[i];
            if(x.equals("+")){
                stack.push(stack.pop()+stack.pop());
            }else if(x.equals("-")){
                stack.push(-stack.pop()+stack.pop());
            }else if(x.equals("*")){
                stack.push(stack.pop()*stack.pop());
            }else{
                int t=Integer.parseInt(x);
                stack.push(t);
            }
        }
        System.out.println(stack.pop());
    }
}