import java.util.Scanner;
import java.util.Stack;

/**
 * Created by ??\??? on 2016/12/6.
 */
public class Main {
    static boolean isNum(String s){
        char[] array = s.toCharArray();
        int flag = 0;
        if(array[0]=='-'&&s.length()>1)
            flag = 1;
        for (char c : array) {
            if(!Character.isDigit(c)){
                flag--;
            }
            if(flag<0)
                return false;
        }
        return true;
    }
    static int si(String s){
        if(isNum(s))
            return Integer.parseInt(s);
        else {
            return -1000000010;
        }
    }
    static int count(String s,String a,String b){
        if(s.equals("+"))
            return si(a)+si(b);
        if(s.equals("-"))
            return si(b)-si(a);
        if(s.equals("*"))
            return si(a)*si(b);
        if(s.equals("/"))
            return si(b)/si(a);
        return -1000000020;
    }
    static int run(String[] args){
        Scanner scan = new Scanner(System.in);
        String[] lines = scan.nextLine().split(" ");
        Stack<String> vs = new Stack<>();
        //Stack<String> os = new Stack<>();
        for (String s:lines) {
            if(isNum(s))
                vs.push(s);
            else{
                String o = s;
                String a = vs.pop();
                String b = vs.pop();
                String c = String.valueOf(count(o,a,b));
                //System.out.println(a+" "+b+" "+c);
                vs.push(c);
            }
        }
        System.out.println(vs.pop());
        return 0;
    }
    public static void main(String[] args){
        run(args);
        //System.out.println(Integer.parseInt("-1"));
    }
} import java.util.Scanner; Scanner java.util import java.util.Stack; Stack java.util public class Main {
    static boolean isNum(String s){
        char[] array = s.toCharArray();
        int flag = 0;
        if(array[0]=='-'&&s.length()>1)
            flag = 1;
        for (char c : array) {
            if(!Character.isDigit(c)){
                flag--;
            }
            if(flag<0)
                return false;
        }
        return true;
    }
    static int si(String s){
        if(isNum(s))
            return Integer.parseInt(s);
        else {
            return -1000000010;
        }
    }
    static int count(String s,String a,String b){
        if(s.equals("+"))
            return si(a)+si(b);
        if(s.equals("-"))
            return si(b)-si(a);
        if(s.equals("*"))
            return si(a)*si(b);
        if(s.equals("/"))
            return si(b)/si(a);
        return -1000000020;
    }
    static int run(String[] args){
        Scanner scan = new Scanner(System.in);
        String[] lines = scan.nextLine().split(" ");
        Stack<String> vs = new Stack<>();
        //Stack<String> os = new Stack<>();
        for (String s:lines) {
            if(isNum(s))
                vs.push(s);
            else{
                String o = s;
                String a = vs.pop();
                String b = vs.pop();
                String c = String.valueOf(count(o,a,b));
                //System.out.println(a+" "+b+" "+c);
                vs.push(c);
            }
        }
        System.out.println(vs.pop());
        return 0;
    }
    public static void main(String[] args){
        run(args);
        //System.out.println(Integer.parseInt("-1"));
    }
} Main static boolean isNum(String s){
        char[] array = s.toCharArray();
        int flag = 0;
        if(array[0]=='-'&&s.length()>1)
            flag = 1;
        for (char c : array) {
            if(!Character.isDigit(c)){
                flag--;
            }
            if(flag<0)
                return false;
        }
        return true;
    } isNum {
        char[] array = s.toCharArray();
        int flag = 0;
        if(array[0]=='-'&&s.length()>1)
            flag = 1;
        for (char c : array) {
            if(!Character.isDigit(c)){
                flag--;
            }
            if(flag<0)
                return false;
        }
        return true;
    } char[] array = s.toCharArray(); array s.toCharArray() s.toCharArray s int flag = 0; flag 0 if(array[0]=='-'&&s.length()>1)
            flag = 1; array[0]=='-'&&s.length()>1 array[0]=='-' array[0] array 0 '-' s.length()>1 s.length() s.length s 1 flag = 1 flag 1 for (char c : array) {
            if(!Character.isDigit(c)){
                flag--;
            }
            if(flag<0)
                return false;
        } char c array {
            if(!Character.isDigit(c)){
                flag--;
            }
            if(flag<0)
                return false;
        } {
            if(!Character.isDigit(c)){
                flag--;
            }
            if(flag<0)
                return false;
        } if(!Character.isDigit(c)){
                flag--;
            } !Character.isDigit(c) Character.isDigit(c) Character.isDigit Character c {
                flag--;
            } flag-- flag if(flag<0)
                return false; flag<0 flag 0 return false; false return true; true String s s static int si(String s){
        if(isNum(s))
            return Integer.parseInt(s);
        else {
            return -1000000010;
        }
    } si {
        if(isNum(s))
            return Integer.parseInt(s);
        else {
            return -1000000010;
        }
    } if(isNum(s))
            return Integer.parseInt(s);
        else {
            return -1000000010;
        } isNum(s) isNum s return Integer.parseInt(s); Integer.parseInt(s) Integer.parseInt Integer s {
            return -1000000010;
        } return -1000000010; -1000000010 1000000010 String s s static int count(String s,String a,String b){
        if(s.equals("+"))
            return si(a)+si(b);
        if(s.equals("-"))
            return si(b)-si(a);
        if(s.equals("*"))
            return si(a)*si(b);
        if(s.equals("/"))
            return si(b)/si(a);
        return -1000000020;
    } count {
        if(s.equals("+"))
            return si(a)+si(b);
        if(s.equals("-"))
            return si(b)-si(a);
        if(s.equals("*"))
            return si(a)*si(b);
        if(s.equals("/"))
            return si(b)/si(a);
        return -1000000020;
    } if(s.equals("+"))
            return si(a)+si(b); s.equals("+") s.equals s "+" return si(a)+si(b); si(a)+si(b) si(a) si a si(b) si b if(s.equals("-"))
            return si(b)-si(a); s.equals("-") s.equals s "-" return si(b)-si(a); si(b)-si(a) si(b) si b si(a) si a if(s.equals("*"))
            return si(a)*si(b); s.equals("*") s.equals s "*" return si(a)*si(b); si(a)*si(b) si(a) si a si(b) si b if(s.equals("/"))
            return si(b)/si(a); s.equals("/") s.equals s "/" return si(b)/si(a); si(b)/si(a) si(b) si b si(a) si a return -1000000020; -1000000020 1000000020 String s s String a a String b b static int run(String[] args){
        Scanner scan = new Scanner(System.in);
        String[] lines = scan.nextLine().split(" ");
        Stack<String> vs = new Stack<>();
        //Stack<String> os = new Stack<>();
        for (String s:lines) {
            if(isNum(s))
                vs.push(s);
            else{
                String o = s;
                String a = vs.pop();
                String b = vs.pop();
                String c = String.valueOf(count(o,a,b));
                //System.out.println(a+" "+b+" "+c);
                vs.push(c);
            }
        }
        System.out.println(vs.pop());
        return 0;
    } run {
        Scanner scan = new Scanner(System.in);
        String[] lines = scan.nextLine().split(" ");
        Stack<String> vs = new Stack<>();
        //Stack<String> os = new Stack<>();
        for (String s:lines) {
            if(isNum(s))
                vs.push(s);
            else{
                String o = s;
                String a = vs.pop();
                String b = vs.pop();
                String c = String.valueOf(count(o,a,b));
                //System.out.println(a+" "+b+" "+c);
                vs.push(c);
            }
        }
        System.out.println(vs.pop());
        return 0;
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String[] lines = scan.nextLine().split(" "); lines scan.nextLine().split(" ") scan.nextLine().split scan.nextLine() scan.nextLine scan " " Stack<String> vs = new Stack<>(); vs new Stack<>() for (String s:lines) {
            if(isNum(s))
                vs.push(s);
            else{
                String o = s;
                String a = vs.pop();
                String b = vs.pop();
                String c = String.valueOf(count(o,a,b));
                //System.out.println(a+" "+b+" "+c);
                vs.push(c);
            }
        } String s lines {
            if(isNum(s))
                vs.push(s);
            else{
                String o = s;
                String a = vs.pop();
                String b = vs.pop();
                String c = String.valueOf(count(o,a,b));
                //System.out.println(a+" "+b+" "+c);
                vs.push(c);
            }
        } {
            if(isNum(s))
                vs.push(s);
            else{
                String o = s;
                String a = vs.pop();
                String b = vs.pop();
                String c = String.valueOf(count(o,a,b));
                //System.out.println(a+" "+b+" "+c);
                vs.push(c);
            }
        } if(isNum(s))
                vs.push(s);
            else{
                String o = s;
                String a = vs.pop();
                String b = vs.pop();
                String c = String.valueOf(count(o,a,b));
                //System.out.println(a+" "+b+" "+c);
                vs.push(c);
            } isNum(s) isNum s vs.push(s) vs.push vs s {
                String o = s;
                String a = vs.pop();
                String b = vs.pop();
                String c = String.valueOf(count(o,a,b));
                //System.out.println(a+" "+b+" "+c);
                vs.push(c);
            } String o = s; o s String a = vs.pop(); a vs.pop() vs.pop vs String b = vs.pop(); b vs.pop() vs.pop vs String c = String.valueOf(count(o,a,b)); c String.valueOf(count(o,a,b)) String.valueOf String count(o,a,b) count o a b vs.push(c) vs.push vs c System.out.println(vs.pop()) System.out.println System.out System System.out vs.pop() vs.pop vs return 0; 0 String[] args args public static void main(String[] args){
        run(args);
        //System.out.println(Integer.parseInt("-1"));
    } main {
        run(args);
        //System.out.println(Integer.parseInt("-1"));
    } run(args) run args String[] args args public class Main {
    static boolean isNum(String s){
        char[] array = s.toCharArray();
        int flag = 0;
        if(array[0]=='-'&&s.length()>1)
            flag = 1;
        for (char c : array) {
            if(!Character.isDigit(c)){
                flag--;
            }
            if(flag<0)
                return false;
        }
        return true;
    }
    static int si(String s){
        if(isNum(s))
            return Integer.parseInt(s);
        else {
            return -1000000010;
        }
    }
    static int count(String s,String a,String b){
        if(s.equals("+"))
            return si(a)+si(b);
        if(s.equals("-"))
            return si(b)-si(a);
        if(s.equals("*"))
            return si(a)*si(b);
        if(s.equals("/"))
            return si(b)/si(a);
        return -1000000020;
    }
    static int run(String[] args){
        Scanner scan = new Scanner(System.in);
        String[] lines = scan.nextLine().split(" ");
        Stack<String> vs = new Stack<>();
        //Stack<String> os = new Stack<>();
        for (String s:lines) {
            if(isNum(s))
                vs.push(s);
            else{
                String o = s;
                String a = vs.pop();
                String b = vs.pop();
                String c = String.valueOf(count(o,a,b));
                //System.out.println(a+" "+b+" "+c);
                vs.push(c);
            }
        }
        System.out.println(vs.pop());
        return 0;
    }
    public static void main(String[] args){
        run(args);
        //System.out.println(Integer.parseInt("-1"));
    }
} public class Main {
    static boolean isNum(String s){
        char[] array = s.toCharArray();
        int flag = 0;
        if(array[0]=='-'&&s.length()>1)
            flag = 1;
        for (char c : array) {
            if(!Character.isDigit(c)){
                flag--;
            }
            if(flag<0)
                return false;
        }
        return true;
    }
    static int si(String s){
        if(isNum(s))
            return Integer.parseInt(s);
        else {
            return -1000000010;
        }
    }
    static int count(String s,String a,String b){
        if(s.equals("+"))
            return si(a)+si(b);
        if(s.equals("-"))
            return si(b)-si(a);
        if(s.equals("*"))
            return si(a)*si(b);
        if(s.equals("/"))
            return si(b)/si(a);
        return -1000000020;
    }
    static int run(String[] args){
        Scanner scan = new Scanner(System.in);
        String[] lines = scan.nextLine().split(" ");
        Stack<String> vs = new Stack<>();
        //Stack<String> os = new Stack<>();
        for (String s:lines) {
            if(isNum(s))
                vs.push(s);
            else{
                String o = s;
                String a = vs.pop();
                String b = vs.pop();
                String c = String.valueOf(count(o,a,b));
                //System.out.println(a+" "+b+" "+c);
                vs.push(c);
            }
        }
        System.out.println(vs.pop());
        return 0;
    }
    public static void main(String[] args){
        run(args);
        //System.out.println(Integer.parseInt("-1"));
    }
} Main
import java.util.Scanner;
import java.util.Stack;

/**
 * Created by ??\??? on 2016/12/6.
 */
public class Main {
    static boolean isNum(String s){
        char[] array = s.toCharArray();
        int flag = 0;
        if(array[0]=='-'&&s.length()>1)
            flag = 1;
        for (char c : array) {
            if(!Character.isDigit(c)){
                flag--;
            }
            if(flag<0)
                return false;
        }
        return true;
    }
    static int si(String s){
        if(isNum(s))
            return Integer.parseInt(s);
        else {
            return -1000000010;
        }
    }
    static int count(String s,String a,String b){
        if(s.equals("+"))
            return si(a)+si(b);
        if(s.equals("-"))
            return si(b)-si(a);
        if(s.equals("*"))
            return si(a)*si(b);
        if(s.equals("/"))
            return si(b)/si(a);
        return -1000000020;
    }
    static int run(String[] args){
        Scanner scan = new Scanner(System.in);
        String[] lines = scan.nextLine().split(" ");
        Stack<String> vs = new Stack<>();
        //Stack<String> os = new Stack<>();
        for (String s:lines) {
            if(isNum(s))
                vs.push(s);
            else{
                String o = s;
                String a = vs.pop();
                String b = vs.pop();
                String c = String.valueOf(count(o,a,b));
                //System.out.println(a+" "+b+" "+c);
                vs.push(c);
            }
        }
        System.out.println(vs.pop());
        return 0;
    }
    public static void main(String[] args){
        run(args);
        //System.out.println(Integer.parseInt("-1"));
    }
}