import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split("\\s");
        Stack<Integer> q = new Stack<Integer>();
        for (int i = 0; i < str.length; i++) {
            if (str[i].equals("+")) {
                q.add(q.pop() + q.pop());
                continue;
            }
            if (str[i].equals("-")) {
		int a1 = q.pop();
		int a2 = q.pop();
                q.add(a2 - a1);
                continue;
            }
            if (str[i].equals("*")) {
                q.add(q.pop() * q.pop());
                continue;
            }
            q.push(Integer.parseInt(str[i]));
        }
        System.out.println(q.pop());
    }
}
 import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Stack; Stack java.util public class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split("\\s");
        Stack<Integer> q = new Stack<Integer>();
        for (int i = 0; i < str.length; i++) {
            if (str[i].equals("+")) {
                q.add(q.pop() + q.pop());
                continue;
            }
            if (str[i].equals("-")) {
		int a1 = q.pop();
		int a2 = q.pop();
                q.add(a2 - a1);
                continue;
            }
            if (str[i].equals("*")) {
                q.add(q.pop() * q.pop());
                continue;
            }
            q.push(Integer.parseInt(str[i]));
        }
        System.out.println(q.pop());
    }
} Main public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split("\\s");
        Stack<Integer> q = new Stack<Integer>();
        for (int i = 0; i < str.length; i++) {
            if (str[i].equals("+")) {
                q.add(q.pop() + q.pop());
                continue;
            }
            if (str[i].equals("-")) {
		int a1 = q.pop();
		int a2 = q.pop();
                q.add(a2 - a1);
                continue;
            }
            if (str[i].equals("*")) {
                q.add(q.pop() * q.pop());
                continue;
            }
            q.push(Integer.parseInt(str[i]));
        }
        System.out.println(q.pop());
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split("\\s");
        Stack<Integer> q = new Stack<Integer>();
        for (int i = 0; i < str.length; i++) {
            if (str[i].equals("+")) {
                q.add(q.pop() + q.pop());
                continue;
            }
            if (str[i].equals("-")) {
		int a1 = q.pop();
		int a2 = q.pop();
                q.add(a2 - a1);
                continue;
            }
            if (str[i].equals("*")) {
                q.add(q.pop() * q.pop());
                continue;
            }
            q.push(Integer.parseInt(str[i]));
        }
        System.out.println(q.pop());
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] str = br.readLine().split("\\s"); str br.readLine().split("\\s") br.readLine().split br.readLine() br.readLine br "\\s" Stack<Integer> q = new Stack<Integer>(); q new Stack<Integer>() for (int i = 0; i < str.length; i++) {
            if (str[i].equals("+")) {
                q.add(q.pop() + q.pop());
                continue;
            }
            if (str[i].equals("-")) {
		int a1 = q.pop();
		int a2 = q.pop();
                q.add(a2 - a1);
                continue;
            }
            if (str[i].equals("*")) {
                q.add(q.pop() * q.pop());
                continue;
            }
            q.push(Integer.parseInt(str[i]));
        } int i = 0; int i = 0; i 0 i < str.length i str.length str str.length i++ i++ i {
            if (str[i].equals("+")) {
                q.add(q.pop() + q.pop());
                continue;
            }
            if (str[i].equals("-")) {
		int a1 = q.pop();
		int a2 = q.pop();
                q.add(a2 - a1);
                continue;
            }
            if (str[i].equals("*")) {
                q.add(q.pop() * q.pop());
                continue;
            }
            q.push(Integer.parseInt(str[i]));
        } {
            if (str[i].equals("+")) {
                q.add(q.pop() + q.pop());
                continue;
            }
            if (str[i].equals("-")) {
		int a1 = q.pop();
		int a2 = q.pop();
                q.add(a2 - a1);
                continue;
            }
            if (str[i].equals("*")) {
                q.add(q.pop() * q.pop());
                continue;
            }
            q.push(Integer.parseInt(str[i]));
        } if (str[i].equals("+")) {
                q.add(q.pop() + q.pop());
                continue;
            } str[i].equals("+") str[i].equals str[i] str i "+" {
                q.add(q.pop() + q.pop());
                continue;
            } q.add(q.pop() + q.pop()) q.add q q.pop() + q.pop() q.pop() q.pop q q.pop() q.pop q continue; if (str[i].equals("-")) {
		int a1 = q.pop();
		int a2 = q.pop();
                q.add(a2 - a1);
                continue;
            } str[i].equals("-") str[i].equals str[i] str i "-" {
		int a1 = q.pop();
		int a2 = q.pop();
                q.add(a2 - a1);
                continue;
            } int a1 = q.pop(); a1 q.pop() q.pop q int a2 = q.pop(); a2 q.pop() q.pop q q.add(a2 - a1) q.add q a2 - a1 a2 a1 continue; if (str[i].equals("*")) {
                q.add(q.pop() * q.pop());
                continue;
            } str[i].equals("*") str[i].equals str[i] str i "*" {
                q.add(q.pop() * q.pop());
                continue;
            } q.add(q.pop() * q.pop()) q.add q q.pop() * q.pop() q.pop() q.pop q q.pop() q.pop q continue; q.push(Integer.parseInt(str[i])) q.push q Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i System.out.println(q.pop()) System.out.println System.out System System.out q.pop() q.pop q String args[] args public class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split("\\s");
        Stack<Integer> q = new Stack<Integer>();
        for (int i = 0; i < str.length; i++) {
            if (str[i].equals("+")) {
                q.add(q.pop() + q.pop());
                continue;
            }
            if (str[i].equals("-")) {
		int a1 = q.pop();
		int a2 = q.pop();
                q.add(a2 - a1);
                continue;
            }
            if (str[i].equals("*")) {
                q.add(q.pop() * q.pop());
                continue;
            }
            q.push(Integer.parseInt(str[i]));
        }
        System.out.println(q.pop());
    }
} public class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split("\\s");
        Stack<Integer> q = new Stack<Integer>();
        for (int i = 0; i < str.length; i++) {
            if (str[i].equals("+")) {
                q.add(q.pop() + q.pop());
                continue;
            }
            if (str[i].equals("-")) {
		int a1 = q.pop();
		int a2 = q.pop();
                q.add(a2 - a1);
                continue;
            }
            if (str[i].equals("*")) {
                q.add(q.pop() * q.pop());
                continue;
            }
            q.push(Integer.parseInt(str[i]));
        }
        System.out.println(q.pop());
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split("\\s");
        Stack<Integer> q = new Stack<Integer>();
        for (int i = 0; i < str.length; i++) {
            if (str[i].equals("+")) {
                q.add(q.pop() + q.pop());
                continue;
            }
            if (str[i].equals("-")) {
		int a1 = q.pop();
		int a2 = q.pop();
                q.add(a2 - a1);
                continue;
            }
            if (str[i].equals("*")) {
                q.add(q.pop() * q.pop());
                continue;
            }
            q.push(Integer.parseInt(str[i]));
        }
        System.out.println(q.pop());
    }
}

