
import javax.xml.crypto.Data;
import java.util.*;
import java.io.*;

public class Main {
    public static int SENTINEL = 100000007;
    public static int MAX = 10007;
    public static int NIL = -1;

    public static int[] dp = new int[100];


    public static void main(String[] args) throws IOException {

        //??\???

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");

        Scanner sc = new Scanner(System.in);

        Stack S = new Stack();
        int a, b;
        for(int i = 0; i < str.length; i++) {
            if(str[i].equals("+")) {
                a = S.pop();
                b = S.pop();
                S.push(a + b);
            }
            else if(str[i].equals("-")) {
                a = S.pop();
                b = S.pop();
                S.push(b - a);
            }
            else if(str[i].equals("*")) {
                a = S.pop();
                b = S.pop();
                S.push(a * b);
            }
            else {
                S.push(Integer.parseInt(str[i]));
            }
        }
        System.out.println(S.pop());
    }

}

class Stack {
    int top;
    int MAX = 10001;
    int[] S = new int[MAX];

    Stack() {
        top = 0;
    }
    boolean isEmpty() {
        return top == 0;
    }
    boolean isFull() {
        return top > MAX;
    }
    void push(int x) {
        if(isFull()) return;
        top++;
        S[top] = x;
    }
    int pop() {
        if(isEmpty()) return -1;
        top--;
        return S[top + 1];
    }
} import javax.xml.crypto.Data; Data javax.xml.crypto import java.util.*; util.* java import java.io.*; io.* java public class Main {
    public static int SENTINEL = 100000007;
    public static int MAX = 10007;
    public static int NIL = -1;

    public static int[] dp = new int[100];


    public static void main(String[] args) throws IOException {

        //??\???

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");

        Scanner sc = new Scanner(System.in);

        Stack S = new Stack();
        int a, b;
        for(int i = 0; i < str.length; i++) {
            if(str[i].equals("+")) {
                a = S.pop();
                b = S.pop();
                S.push(a + b);
            }
            else if(str[i].equals("-")) {
                a = S.pop();
                b = S.pop();
                S.push(b - a);
            }
            else if(str[i].equals("*")) {
                a = S.pop();
                b = S.pop();
                S.push(a * b);
            }
            else {
                S.push(Integer.parseInt(str[i]));
            }
        }
        System.out.println(S.pop());
    }

} Main public static int SENTINEL = 100000007; SENTINEL 100000007 public static int MAX = 10007; MAX 10007 public static int NIL = -1; NIL -1 1 public static int[] dp = new int[100]; dp new int[100] 100 public static void main(String[] args) throws IOException {

        //??\???

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");

        Scanner sc = new Scanner(System.in);

        Stack S = new Stack();
        int a, b;
        for(int i = 0; i < str.length; i++) {
            if(str[i].equals("+")) {
                a = S.pop();
                b = S.pop();
                S.push(a + b);
            }
            else if(str[i].equals("-")) {
                a = S.pop();
                b = S.pop();
                S.push(b - a);
            }
            else if(str[i].equals("*")) {
                a = S.pop();
                b = S.pop();
                S.push(a * b);
            }
            else {
                S.push(Integer.parseInt(str[i]));
            }
        }
        System.out.println(S.pop());
    } main {

        //??\???

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");

        Scanner sc = new Scanner(System.in);

        Stack S = new Stack();
        int a, b;
        for(int i = 0; i < str.length; i++) {
            if(str[i].equals("+")) {
                a = S.pop();
                b = S.pop();
                S.push(a + b);
            }
            else if(str[i].equals("-")) {
                a = S.pop();
                b = S.pop();
                S.push(b - a);
            }
            else if(str[i].equals("*")) {
                a = S.pop();
                b = S.pop();
                S.push(a * b);
            }
            else {
                S.push(Integer.parseInt(str[i]));
            }
        }
        System.out.println(S.pop());
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] str = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Stack S = new Stack(); S new Stack() int a a b; b for(int i = 0; i < str.length; i++) {
            if(str[i].equals("+")) {
                a = S.pop();
                b = S.pop();
                S.push(a + b);
            }
            else if(str[i].equals("-")) {
                a = S.pop();
                b = S.pop();
                S.push(b - a);
            }
            else if(str[i].equals("*")) {
                a = S.pop();
                b = S.pop();
                S.push(a * b);
            }
            else {
                S.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("+")) {
                a = S.pop();
                b = S.pop();
                S.push(a + b);
            }
            else if(str[i].equals("-")) {
                a = S.pop();
                b = S.pop();
                S.push(b - a);
            }
            else if(str[i].equals("*")) {
                a = S.pop();
                b = S.pop();
                S.push(a * b);
            }
            else {
                S.push(Integer.parseInt(str[i]));
            }
        } {
            if(str[i].equals("+")) {
                a = S.pop();
                b = S.pop();
                S.push(a + b);
            }
            else if(str[i].equals("-")) {
                a = S.pop();
                b = S.pop();
                S.push(b - a);
            }
            else if(str[i].equals("*")) {
                a = S.pop();
                b = S.pop();
                S.push(a * b);
            }
            else {
                S.push(Integer.parseInt(str[i]));
            }
        } if(str[i].equals("+")) {
                a = S.pop();
                b = S.pop();
                S.push(a + b);
            }
            else if(str[i].equals("-")) {
                a = S.pop();
                b = S.pop();
                S.push(b - a);
            }
            else if(str[i].equals("*")) {
                a = S.pop();
                b = S.pop();
                S.push(a * b);
            }
            else {
                S.push(Integer.parseInt(str[i]));
            } str[i].equals("+") str[i].equals str[i] str i "+" {
                a = S.pop();
                b = S.pop();
                S.push(a + b);
            } a = S.pop() a S.pop() S.pop S b = S.pop() b S.pop() S.pop S S.push(a + b) S.push S a + b a b if(str[i].equals("-")) {
                a = S.pop();
                b = S.pop();
                S.push(b - a);
            }
            else if(str[i].equals("*")) {
                a = S.pop();
                b = S.pop();
                S.push(a * b);
            }
            else {
                S.push(Integer.parseInt(str[i]));
            } str[i].equals("-") str[i].equals str[i] str i "-" {
                a = S.pop();
                b = S.pop();
                S.push(b - a);
            } a = S.pop() a S.pop() S.pop S b = S.pop() b S.pop() S.pop S S.push(b - a) S.push S b - a b a if(str[i].equals("*")) {
                a = S.pop();
                b = S.pop();
                S.push(a * b);
            }
            else {
                S.push(Integer.parseInt(str[i]));
            } str[i].equals("*") str[i].equals str[i] str i "*" {
                a = S.pop();
                b = S.pop();
                S.push(a * b);
            } a = S.pop() a S.pop() S.pop S b = S.pop() b S.pop() S.pop S S.push(a * b) S.push S a * b a b {
                S.push(Integer.parseInt(str[i]));
            } S.push(Integer.parseInt(str[i])) S.push S Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i System.out.println(S.pop()) System.out.println System.out System System.out S.pop() S.pop S String[] args args class Stack {
    int top;
    int MAX = 10001;
    int[] S = new int[MAX];

    Stack() {
        top = 0;
    }
    boolean isEmpty() {
        return top == 0;
    }
    boolean isFull() {
        return top > MAX;
    }
    void push(int x) {
        if(isFull()) return;
        top++;
        S[top] = x;
    }
    int pop() {
        if(isEmpty()) return -1;
        top--;
        return S[top + 1];
    }
} Stack int top; top int MAX = 10001; MAX 10001 int[] S = new int[MAX]; S new int[MAX] MAX Stack() {
        top = 0;
    } Stack {
        top = 0;
    } top = 0 top 0 boolean isEmpty() {
        return top == 0;
    } isEmpty {
        return top == 0;
    } return top == 0; top == 0 top 0 boolean isFull() {
        return top > MAX;
    } isFull {
        return top > MAX;
    } return top > MAX; top > MAX top MAX void push(int x) {
        if(isFull()) return;
        top++;
        S[top] = x;
    } push {
        if(isFull()) return;
        top++;
        S[top] = x;
    } if(isFull()) return; isFull() isFull return; top++ top S[top] = x S[top] S top x int x x int pop() {
        if(isEmpty()) return -1;
        top--;
        return S[top + 1];
    } pop {
        if(isEmpty()) return -1;
        top--;
        return S[top + 1];
    } if(isEmpty()) return -1; isEmpty() isEmpty return -1; -1 1 top-- top return S[top + 1]; S[top + 1] S top + 1 top 1 public class Main {
    public static int SENTINEL = 100000007;
    public static int MAX = 10007;
    public static int NIL = -1;

    public static int[] dp = new int[100];


    public static void main(String[] args) throws IOException {

        //??\???

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");

        Scanner sc = new Scanner(System.in);

        Stack S = new Stack();
        int a, b;
        for(int i = 0; i < str.length; i++) {
            if(str[i].equals("+")) {
                a = S.pop();
                b = S.pop();
                S.push(a + b);
            }
            else if(str[i].equals("-")) {
                a = S.pop();
                b = S.pop();
                S.push(b - a);
            }
            else if(str[i].equals("*")) {
                a = S.pop();
                b = S.pop();
                S.push(a * b);
            }
            else {
                S.push(Integer.parseInt(str[i]));
            }
        }
        System.out.println(S.pop());
    }

} public class Main {
    public static int SENTINEL = 100000007;
    public static int MAX = 10007;
    public static int NIL = -1;

    public static int[] dp = new int[100];


    public static void main(String[] args) throws IOException {

        //??\???

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");

        Scanner sc = new Scanner(System.in);

        Stack S = new Stack();
        int a, b;
        for(int i = 0; i < str.length; i++) {
            if(str[i].equals("+")) {
                a = S.pop();
                b = S.pop();
                S.push(a + b);
            }
            else if(str[i].equals("-")) {
                a = S.pop();
                b = S.pop();
                S.push(b - a);
            }
            else if(str[i].equals("*")) {
                a = S.pop();
                b = S.pop();
                S.push(a * b);
            }
            else {
                S.push(Integer.parseInt(str[i]));
            }
        }
        System.out.println(S.pop());
    }

} Main

import javax.xml.crypto.Data;
import java.util.*;
import java.io.*;

public class Main {
    public static int SENTINEL = 100000007;
    public static int MAX = 10007;
    public static int NIL = -1;

    public static int[] dp = new int[100];


    public static void main(String[] args) throws IOException {

        //??\???

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");

        Scanner sc = new Scanner(System.in);

        Stack S = new Stack();
        int a, b;
        for(int i = 0; i < str.length; i++) {
            if(str[i].equals("+")) {
                a = S.pop();
                b = S.pop();
                S.push(a + b);
            }
            else if(str[i].equals("-")) {
                a = S.pop();
                b = S.pop();
                S.push(b - a);
            }
            else if(str[i].equals("*")) {
                a = S.pop();
                b = S.pop();
                S.push(a * b);
            }
            else {
                S.push(Integer.parseInt(str[i]));
            }
        }
        System.out.println(S.pop());
    }

}

class Stack {
    int top;
    int MAX = 10001;
    int[] S = new int[MAX];

    Stack() {
        top = 0;
    }
    boolean isEmpty() {
        return top == 0;
    }
    boolean isFull() {
        return top > MAX;
    }
    void push(int x) {
        if(isFull()) return;
        top++;
        S[top] = x;
    }
    int pop() {
        if(isEmpty()) return -1;
        top--;
        return S[top + 1];
    }
}