let () =
  let open Stack in
  let s = create () in
  let l = Str.split (Str.regexp " ") (read_line ()) in
  let doit = function
    | "+" -> let x = pop s and y = pop s in push (y + x) s
    | "-" -> let x = pop s and y = pop s in push (y - x) s
    | "*" -> let x = pop s and y = pop s in push (y * x) s
    | n -> push (int_of_string n) s
  in
  List.iter doit l;
  Printf.printf "%d\n" (pop s)