let eval l =
  let interpret_op = function "+" -> (+) | "-" -> (-) | _ -> ( * ) in
  let s = Stack.create () in
  let rec aux = function
      [] -> Stack.pop s
    | op::r when op="+" || op="*" || op="-" ->
      let a,b = Stack.pop s, Stack.pop s in
      Stack.push ((interpret_op op) a b) s;
      aux r
    | n::r ->
      Stack.push (int_of_string n) s;
      aux r
  in aux l

let () =
  let l = read_line () |> Str.split (Str.regexp " ") in
  Printf.printf "%d\n" (eval l)