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

class myStack {
    // s[0]には常に何も入れない実装
    int size = 200;
    String[] s;
    int top;

    myStack() {
        s = new String[size];
        top = 0;
    }

    void initialize() {
        top = 0;
    }

    void push(String x) {
        if (isFull()) {
            System.err.println("stack overflow!");
            return;
        }

        s[++top] = x;
    }

    String pop() {
        if (isEmpty()) {
            System.err.println("stack is empty!");
            return null;
        }
        return s[top--];
    }

    boolean isEmpty() {
        return (top == 0);
    }

    boolean isFull() {
        return (top >= size - 1);
    }

    int eval() {
        String val = this.pop();
        if (isNumber(val)) {
            return Integer.parseInt(val);
        }

        int b = eval();
        int a = eval();

        switch (val) {
        case "+":
            return a + b;
        case "-":
            return a - b;
        case "*":
            return a * b;
        } 

        return 0; // unreachable
    }

    boolean isNumber(String x) {
        try {
            Integer.parseInt(x);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }

}

class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] input = br.readLine().split(" ");
        myStack ms = new myStack();

        for (String s : input) {
            ms.push(s);
        }

        // evaluate
        while (ms.top != 1) {
            ms.push(String.valueOf(ms.eval()));
        }

        System.out.println(ms.pop());
    }
} import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.BufferedReader; BufferedReader java.io class myStack {
    // s[0]には常に何も入れない実装
    int size = 200;
    String[] s;
    int top;

    myStack() {
        s = new String[size];
        top = 0;
    }

    void initialize() {
        top = 0;
    }

    void push(String x) {
        if (isFull()) {
            System.err.println("stack overflow!");
            return;
        }

        s[++top] = x;
    }

    String pop() {
        if (isEmpty()) {
            System.err.println("stack is empty!");
            return null;
        }
        return s[top--];
    }

    boolean isEmpty() {
        return (top == 0);
    }

    boolean isFull() {
        return (top >= size - 1);
    }

    int eval() {
        String val = this.pop();
        if (isNumber(val)) {
            return Integer.parseInt(val);
        }

        int b = eval();
        int a = eval();

        switch (val) {
        case "+":
            return a + b;
        case "-":
            return a - b;
        case "*":
            return a * b;
        } 

        return 0; // unreachable
    }

    boolean isNumber(String x) {
        try {
            Integer.parseInt(x);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }

} myStack // s[0]には常に何も入れない実装
    int size = 200; size 200 String[] s; s int top; top myStack() {
        s = new String[size];
        top = 0;
    } myStack {
        s = new String[size];
        top = 0;
    } s = new String[size] s new String[size] size top = 0 top 0 void initialize() {
        top = 0;
    } initialize {
        top = 0;
    } top = 0 top 0 void push(String x) {
        if (isFull()) {
            System.err.println("stack overflow!");
            return;
        }

        s[++top] = x;
    } push {
        if (isFull()) {
            System.err.println("stack overflow!");
            return;
        }

        s[++top] = x;
    } if (isFull()) {
            System.err.println("stack overflow!");
            return;
        } isFull() isFull {
            System.err.println("stack overflow!");
            return;
        } System.err.println("stack overflow!") System.err.println System.err System System.err "stack overflow!" return; s[++top] = x s[++top] s ++top top x String x x String pop() {
        if (isEmpty()) {
            System.err.println("stack is empty!");
            return null;
        }
        return s[top--];
    } pop {
        if (isEmpty()) {
            System.err.println("stack is empty!");
            return null;
        }
        return s[top--];
    } if (isEmpty()) {
            System.err.println("stack is empty!");
            return null;
        } isEmpty() isEmpty {
            System.err.println("stack is empty!");
            return null;
        } System.err.println("stack is empty!") System.err.println System.err System System.err "stack is empty!" return null; null return s[top--]; s[top--] s top-- top boolean isEmpty() {
        return (top == 0);
    } isEmpty {
        return (top == 0);
    } return (top == 0); (top == 0) top 0 boolean isFull() {
        return (top >= size - 1);
    } isFull {
        return (top >= size - 1);
    } return (top >= size - 1); (top >= size - 1) top size - 1 size 1 int eval() {
        String val = this.pop();
        if (isNumber(val)) {
            return Integer.parseInt(val);
        }

        int b = eval();
        int a = eval();

        switch (val) {
        case "+":
            return a + b;
        case "-":
            return a - b;
        case "*":
            return a * b;
        } 

        return 0; // unreachable
    } eval {
        String val = this.pop();
        if (isNumber(val)) {
            return Integer.parseInt(val);
        }

        int b = eval();
        int a = eval();

        switch (val) {
        case "+":
            return a + b;
        case "-":
            return a - b;
        case "*":
            return a * b;
        } 

        return 0; // unreachable
    } String val = this.pop(); val this.pop() this.pop this if (isNumber(val)) {
            return Integer.parseInt(val);
        } isNumber(val) isNumber val {
            return Integer.parseInt(val);
        } return Integer.parseInt(val); Integer.parseInt(val) Integer.parseInt Integer val int b = eval(); b eval() eval int a = eval(); a eval() eval switch (val) {
        case "+":
            return a + b;
        case "-":
            return a - b;
        case "*":
            return a * b;
        } val case "+": "+" case "+": return a + b; a + b a b case "-": "-" case "-": return a - b; a - b a b case "*": "*" case "*": return a * b; a * b a b return 0; // unreachable 0 boolean isNumber(String x) {
        try {
            Integer.parseInt(x);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    } isNumber {
        try {
            Integer.parseInt(x);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    } try {
            Integer.parseInt(x);
            return true;
        } catch (NumberFormatException e) {
            return false;
        } catch (NumberFormatException e) {
            return false;
        } NumberFormatException e {
            return false;
        } return false; false {
            Integer.parseInt(x);
            return true;
        } Integer.parseInt(x) Integer.parseInt Integer x return true; true String x x class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] input = br.readLine().split(" ");
        myStack ms = new myStack();

        for (String s : input) {
            ms.push(s);
        }

        // evaluate
        while (ms.top != 1) {
            ms.push(String.valueOf(ms.eval()));
        }

        System.out.println(ms.pop());
    }
} Main public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] input = br.readLine().split(" ");
        myStack ms = new myStack();

        for (String s : input) {
            ms.push(s);
        }

        // evaluate
        while (ms.top != 1) {
            ms.push(String.valueOf(ms.eval()));
        }

        System.out.println(ms.pop());
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] input = br.readLine().split(" ");
        myStack ms = new myStack();

        for (String s : input) {
            ms.push(s);
        }

        // evaluate
        while (ms.top != 1) {
            ms.push(String.valueOf(ms.eval()));
        }

        System.out.println(ms.pop());
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] input = br.readLine().split(" "); input br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " myStack ms = new myStack(); ms new myStack() for (String s : input) {
            ms.push(s);
        } String s input {
            ms.push(s);
        } {
            ms.push(s);
        } ms.push(s) ms.push ms s while (ms.top != 1) {
            ms.push(String.valueOf(ms.eval()));
        } ms.top != 1 ms.top ms ms.top 1 {
            ms.push(String.valueOf(ms.eval()));
        } ms.push(String.valueOf(ms.eval())) ms.push ms String.valueOf(ms.eval()) String.valueOf String ms.eval() ms.eval ms System.out.println(ms.pop()) System.out.println System.out System System.out ms.pop() ms.pop ms String[] args args
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

class myStack {
    // s[0]には常に何も入れない実装
    int size = 200;
    String[] s;
    int top;

    myStack() {
        s = new String[size];
        top = 0;
    }

    void initialize() {
        top = 0;
    }

    void push(String x) {
        if (isFull()) {
            System.err.println("stack overflow!");
            return;
        }

        s[++top] = x;
    }

    String pop() {
        if (isEmpty()) {
            System.err.println("stack is empty!");
            return null;
        }
        return s[top--];
    }

    boolean isEmpty() {
        return (top == 0);
    }

    boolean isFull() {
        return (top >= size - 1);
    }

    int eval() {
        String val = this.pop();
        if (isNumber(val)) {
            return Integer.parseInt(val);
        }

        int b = eval();
        int a = eval();

        switch (val) {
        case "+":
            return a + b;
        case "-":
            return a - b;
        case "*":
            return a * b;
        } 

        return 0; // unreachable
    }

    boolean isNumber(String x) {
        try {
            Integer.parseInt(x);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }

}

class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] input = br.readLine().split(" ");
        myStack ms = new myStack();

        for (String s : input) {
            ms.push(s);
        }

        // evaluate
        while (ms.top != 1) {
            ms.push(String.valueOf(ms.eval()));
        }

        System.out.println(ms.pop());
    }
}
