import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

immutable long mod = 10^^9 + 7;
immutable int inf = mod;

void main(){
    auto s = readln.split;

    auto stack = new SList!int;
    int x, y, res;

    foreach(si ; s){
        if(si == "+" || si == "-" || si == "*"){
            x = stack.front; stack.removeFront;
            y = stack.front; stack.removeFront;

            if (si == "+") {
                res = x + y;
            }
            else if (si == "-") {
                res = y - x;
            }
            else{
                res = x * y;
            }

            stack.insert(res);
        }
        else {
            stack.insert(si.to!int);
        }
    }

    int ans = stack.front;
    writeln(ans);
}

void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}