import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Deque<String> ad = new ArrayDeque<String>();
        String[] lines = br.readLine().split(" ");
        for (int i = 0; i < lines.length; i++) {
            if (isNumber(lines[i])) {
                ad.push(lines[i]);
            } else {
                if (lines[i].equals("+")) {
                    ad.push(String.valueOf(ip(ad.pop()) + ip(ad.pop())));
                } else if (lines[i].equals("-")) {
                    ad.push(String.valueOf(-ip(ad.pop()) + ip(ad.pop())));
                } else {
                    ad.push(String.valueOf(ip(ad.pop()) * ip(ad.pop())));
                }
            }
        }
        System.out.println(ad.pop());
    }

    static boolean isNumber(String num) {
        return Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$").matcher(num).find();
    }

    static int[] createListInt(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        int[] list = new int[n];
        while (n-- > 0) {
            list[n] = Integer.parseInt(lines[n]);
        }
        return list;
    }

    static long[] createListLong(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        long[] list = new long[n];
        while (n-- > 0) {
            list[n] = Long.parseLong(lines[n]);
        }
        return list;
    }

    static int ip(String s) {
        return Integer.parseInt(s);
    }

    static long lp(String s) {
        return Long.parseLong(s);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayDeque; ArrayDeque java.util import java.util.Deque; Deque java.util import java.util.regex.Pattern; Pattern java.util.regex public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Deque<String> ad = new ArrayDeque<String>();
        String[] lines = br.readLine().split(" ");
        for (int i = 0; i < lines.length; i++) {
            if (isNumber(lines[i])) {
                ad.push(lines[i]);
            } else {
                if (lines[i].equals("+")) {
                    ad.push(String.valueOf(ip(ad.pop()) + ip(ad.pop())));
                } else if (lines[i].equals("-")) {
                    ad.push(String.valueOf(-ip(ad.pop()) + ip(ad.pop())));
                } else {
                    ad.push(String.valueOf(ip(ad.pop()) * ip(ad.pop())));
                }
            }
        }
        System.out.println(ad.pop());
    }

    static boolean isNumber(String num) {
        return Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$").matcher(num).find();
    }

    static int[] createListInt(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        int[] list = new int[n];
        while (n-- > 0) {
            list[n] = Integer.parseInt(lines[n]);
        }
        return list;
    }

    static long[] createListLong(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        long[] list = new long[n];
        while (n-- > 0) {
            list[n] = Long.parseLong(lines[n]);
        }
        return list;
    }

    static int ip(String s) {
        return Integer.parseInt(s);
    }

    static long lp(String s) {
        return Long.parseLong(s);
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Deque<String> ad = new ArrayDeque<String>();
        String[] lines = br.readLine().split(" ");
        for (int i = 0; i < lines.length; i++) {
            if (isNumber(lines[i])) {
                ad.push(lines[i]);
            } else {
                if (lines[i].equals("+")) {
                    ad.push(String.valueOf(ip(ad.pop()) + ip(ad.pop())));
                } else if (lines[i].equals("-")) {
                    ad.push(String.valueOf(-ip(ad.pop()) + ip(ad.pop())));
                } else {
                    ad.push(String.valueOf(ip(ad.pop()) * ip(ad.pop())));
                }
            }
        }
        System.out.println(ad.pop());
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Deque<String> ad = new ArrayDeque<String>();
        String[] lines = br.readLine().split(" ");
        for (int i = 0; i < lines.length; i++) {
            if (isNumber(lines[i])) {
                ad.push(lines[i]);
            } else {
                if (lines[i].equals("+")) {
                    ad.push(String.valueOf(ip(ad.pop()) + ip(ad.pop())));
                } else if (lines[i].equals("-")) {
                    ad.push(String.valueOf(-ip(ad.pop()) + ip(ad.pop())));
                } else {
                    ad.push(String.valueOf(ip(ad.pop()) * ip(ad.pop())));
                }
            }
        }
        System.out.println(ad.pop());
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) Deque<String> ad = new ArrayDeque<String>(); ad new ArrayDeque<String>() String[] lines = br.readLine().split(" "); lines br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " for (int i = 0; i < lines.length; i++) {
            if (isNumber(lines[i])) {
                ad.push(lines[i]);
            } else {
                if (lines[i].equals("+")) {
                    ad.push(String.valueOf(ip(ad.pop()) + ip(ad.pop())));
                } else if (lines[i].equals("-")) {
                    ad.push(String.valueOf(-ip(ad.pop()) + ip(ad.pop())));
                } else {
                    ad.push(String.valueOf(ip(ad.pop()) * ip(ad.pop())));
                }
            }
        } int i = 0; int i = 0; i 0 i < lines.length i lines.length lines lines.length i++ i++ i {
            if (isNumber(lines[i])) {
                ad.push(lines[i]);
            } else {
                if (lines[i].equals("+")) {
                    ad.push(String.valueOf(ip(ad.pop()) + ip(ad.pop())));
                } else if (lines[i].equals("-")) {
                    ad.push(String.valueOf(-ip(ad.pop()) + ip(ad.pop())));
                } else {
                    ad.push(String.valueOf(ip(ad.pop()) * ip(ad.pop())));
                }
            }
        } {
            if (isNumber(lines[i])) {
                ad.push(lines[i]);
            } else {
                if (lines[i].equals("+")) {
                    ad.push(String.valueOf(ip(ad.pop()) + ip(ad.pop())));
                } else if (lines[i].equals("-")) {
                    ad.push(String.valueOf(-ip(ad.pop()) + ip(ad.pop())));
                } else {
                    ad.push(String.valueOf(ip(ad.pop()) * ip(ad.pop())));
                }
            }
        } if (isNumber(lines[i])) {
                ad.push(lines[i]);
            } else {
                if (lines[i].equals("+")) {
                    ad.push(String.valueOf(ip(ad.pop()) + ip(ad.pop())));
                } else if (lines[i].equals("-")) {
                    ad.push(String.valueOf(-ip(ad.pop()) + ip(ad.pop())));
                } else {
                    ad.push(String.valueOf(ip(ad.pop()) * ip(ad.pop())));
                }
            } isNumber(lines[i]) isNumber lines[i] lines i {
                ad.push(lines[i]);
            } ad.push(lines[i]) ad.push ad lines[i] lines i {
                if (lines[i].equals("+")) {
                    ad.push(String.valueOf(ip(ad.pop()) + ip(ad.pop())));
                } else if (lines[i].equals("-")) {
                    ad.push(String.valueOf(-ip(ad.pop()) + ip(ad.pop())));
                } else {
                    ad.push(String.valueOf(ip(ad.pop()) * ip(ad.pop())));
                }
            } if (lines[i].equals("+")) {
                    ad.push(String.valueOf(ip(ad.pop()) + ip(ad.pop())));
                } else if (lines[i].equals("-")) {
                    ad.push(String.valueOf(-ip(ad.pop()) + ip(ad.pop())));
                } else {
                    ad.push(String.valueOf(ip(ad.pop()) * ip(ad.pop())));
                } lines[i].equals("+") lines[i].equals lines[i] lines i "+" {
                    ad.push(String.valueOf(ip(ad.pop()) + ip(ad.pop())));
                } ad.push(String.valueOf(ip(ad.pop()) + ip(ad.pop()))) ad.push ad String.valueOf(ip(ad.pop()) + ip(ad.pop())) String.valueOf String ip(ad.pop()) + ip(ad.pop()) ip(ad.pop()) ip ad.pop() ad.pop ad ip(ad.pop()) ip ad.pop() ad.pop ad if (lines[i].equals("-")) {
                    ad.push(String.valueOf(-ip(ad.pop()) + ip(ad.pop())));
                } else {
                    ad.push(String.valueOf(ip(ad.pop()) * ip(ad.pop())));
                } lines[i].equals("-") lines[i].equals lines[i] lines i "-" {
                    ad.push(String.valueOf(-ip(ad.pop()) + ip(ad.pop())));
                } ad.push(String.valueOf(-ip(ad.pop()) + ip(ad.pop()))) ad.push ad String.valueOf(-ip(ad.pop()) + ip(ad.pop())) String.valueOf String -ip(ad.pop()) + ip(ad.pop()) -ip(ad.pop()) ip(ad.pop()) ip ad.pop() ad.pop ad ip(ad.pop()) ip ad.pop() ad.pop ad {
                    ad.push(String.valueOf(ip(ad.pop()) * ip(ad.pop())));
                } ad.push(String.valueOf(ip(ad.pop()) * ip(ad.pop()))) ad.push ad String.valueOf(ip(ad.pop()) * ip(ad.pop())) String.valueOf String ip(ad.pop()) * ip(ad.pop()) ip(ad.pop()) ip ad.pop() ad.pop ad ip(ad.pop()) ip ad.pop() ad.pop ad System.out.println(ad.pop()) System.out.println System.out System System.out ad.pop() ad.pop ad String[] args args static boolean isNumber(String num) {
        return Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$").matcher(num).find();
    } isNumber {
        return Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$").matcher(num).find();
    } return Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$").matcher(num).find(); Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$").matcher(num).find() Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$").matcher(num).find Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$").matcher(num) Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$").matcher Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$") Pattern.compile Pattern "^\\-?[0-9]*\\.?[0-9]+$" num String num num static int[] createListInt(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        int[] list = new int[n];
        while (n-- > 0) {
            list[n] = Integer.parseInt(lines[n]);
        }
        return list;
    } createListInt {
        String[] lines = line.split(" ");
        int n = lines.length;
        int[] list = new int[n];
        while (n-- > 0) {
            list[n] = Integer.parseInt(lines[n]);
        }
        return list;
    } String[] lines = line.split(" "); lines line.split(" ") line.split line " " int n = lines.length; n lines.length lines lines.length int[] list = new int[n]; list new int[n] n while (n-- > 0) {
            list[n] = Integer.parseInt(lines[n]);
        } n-- > 0 n-- n 0 {
            list[n] = Integer.parseInt(lines[n]);
        } list[n] = Integer.parseInt(lines[n]) list[n] list n Integer.parseInt(lines[n]) Integer.parseInt Integer lines[n] lines n return list; list String line line static long[] createListLong(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        long[] list = new long[n];
        while (n-- > 0) {
            list[n] = Long.parseLong(lines[n]);
        }
        return list;
    } createListLong {
        String[] lines = line.split(" ");
        int n = lines.length;
        long[] list = new long[n];
        while (n-- > 0) {
            list[n] = Long.parseLong(lines[n]);
        }
        return list;
    } String[] lines = line.split(" "); lines line.split(" ") line.split line " " int n = lines.length; n lines.length lines lines.length long[] list = new long[n]; list new long[n] n while (n-- > 0) {
            list[n] = Long.parseLong(lines[n]);
        } n-- > 0 n-- n 0 {
            list[n] = Long.parseLong(lines[n]);
        } list[n] = Long.parseLong(lines[n]) list[n] list n Long.parseLong(lines[n]) Long.parseLong Long lines[n] lines n return list; list String line line static int ip(String s) {
        return Integer.parseInt(s);
    } ip {
        return Integer.parseInt(s);
    } return Integer.parseInt(s); Integer.parseInt(s) Integer.parseInt Integer s String s s static long lp(String s) {
        return Long.parseLong(s);
    } lp {
        return Long.parseLong(s);
    } return Long.parseLong(s); Long.parseLong(s) Long.parseLong Long s String s s public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Deque<String> ad = new ArrayDeque<String>();
        String[] lines = br.readLine().split(" ");
        for (int i = 0; i < lines.length; i++) {
            if (isNumber(lines[i])) {
                ad.push(lines[i]);
            } else {
                if (lines[i].equals("+")) {
                    ad.push(String.valueOf(ip(ad.pop()) + ip(ad.pop())));
                } else if (lines[i].equals("-")) {
                    ad.push(String.valueOf(-ip(ad.pop()) + ip(ad.pop())));
                } else {
                    ad.push(String.valueOf(ip(ad.pop()) * ip(ad.pop())));
                }
            }
        }
        System.out.println(ad.pop());
    }

    static boolean isNumber(String num) {
        return Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$").matcher(num).find();
    }

    static int[] createListInt(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        int[] list = new int[n];
        while (n-- > 0) {
            list[n] = Integer.parseInt(lines[n]);
        }
        return list;
    }

    static long[] createListLong(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        long[] list = new long[n];
        while (n-- > 0) {
            list[n] = Long.parseLong(lines[n]);
        }
        return list;
    }

    static int ip(String s) {
        return Integer.parseInt(s);
    }

    static long lp(String s) {
        return Long.parseLong(s);
    }
} public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Deque<String> ad = new ArrayDeque<String>();
        String[] lines = br.readLine().split(" ");
        for (int i = 0; i < lines.length; i++) {
            if (isNumber(lines[i])) {
                ad.push(lines[i]);
            } else {
                if (lines[i].equals("+")) {
                    ad.push(String.valueOf(ip(ad.pop()) + ip(ad.pop())));
                } else if (lines[i].equals("-")) {
                    ad.push(String.valueOf(-ip(ad.pop()) + ip(ad.pop())));
                } else {
                    ad.push(String.valueOf(ip(ad.pop()) * ip(ad.pop())));
                }
            }
        }
        System.out.println(ad.pop());
    }

    static boolean isNumber(String num) {
        return Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$").matcher(num).find();
    }

    static int[] createListInt(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        int[] list = new int[n];
        while (n-- > 0) {
            list[n] = Integer.parseInt(lines[n]);
        }
        return list;
    }

    static long[] createListLong(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        long[] list = new long[n];
        while (n-- > 0) {
            list[n] = Long.parseLong(lines[n]);
        }
        return list;
    }

    static int ip(String s) {
        return Integer.parseInt(s);
    }

    static long lp(String s) {
        return Long.parseLong(s);
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Deque<String> ad = new ArrayDeque<String>();
        String[] lines = br.readLine().split(" ");
        for (int i = 0; i < lines.length; i++) {
            if (isNumber(lines[i])) {
                ad.push(lines[i]);
            } else {
                if (lines[i].equals("+")) {
                    ad.push(String.valueOf(ip(ad.pop()) + ip(ad.pop())));
                } else if (lines[i].equals("-")) {
                    ad.push(String.valueOf(-ip(ad.pop()) + ip(ad.pop())));
                } else {
                    ad.push(String.valueOf(ip(ad.pop()) * ip(ad.pop())));
                }
            }
        }
        System.out.println(ad.pop());
    }

    static boolean isNumber(String num) {
        return Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$").matcher(num).find();
    }

    static int[] createListInt(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        int[] list = new int[n];
        while (n-- > 0) {
            list[n] = Integer.parseInt(lines[n]);
        }
        return list;
    }

    static long[] createListLong(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        long[] list = new long[n];
        while (n-- > 0) {
            list[n] = Long.parseLong(lines[n]);
        }
        return list;
    }

    static int ip(String s) {
        return Integer.parseInt(s);
    }

    static long lp(String s) {
        return Long.parseLong(s);
    }
}