(* parser ????????????
exp    = term _exp
_exp   = + term _exp | eps
term   = factor _term
_term  = * factor _term | eps
factor = ( exp ) | num
num    = digit(digit)*
digit  = 0-9
*)

let s = ref ""
let length = ref 0
let cur = ref 0

let str_access n =
  if ( n < !length ) then (String.get !s n)
  else '#'

let digit ()=
  let a = Char.escaped (str_access !cur)  in
  (cur:=!cur+1;int_of_string a)

let rec number () =
  let n = ref (digit()) in
  while (!cur < !length && (str_access !cur) >= '0' && (str_access !cur) <= '9') do
    n := 10 * !n + digit()
  done ; !n

and factor ()=
  match (str_access !cur) with
    '(' -> (cur := !cur+1;let n=expr() in cur := !cur+1; n)
  | _   -> number()

and term ()=
  let n = factor() in (_term n)

and _term m =
  match (str_access !cur) with
    '*' -> (cur := !cur+1;let n = m*(factor()) in (_term n))
  | '/' -> (cur := !cur+1;let n = m/(factor()) in (_term n))
  | _   -> m

and expr ()=
  let n = term ()in (_expr n)

and _expr m =
  match (str_access !cur) with
    '+' -> (cur := !cur+1;let n = m+(term()) in (_expr n))
  | '-' -> (cur := !cur+1;let n = m-(term()) in (_expr n))
  | _   -> m

and parse () = expr ();;

(* main *)
ignore ( read_line () )

let rec loop() =
  try
    s := read_line();
    length := String.length !s;
    cur := 0;
    print_int @@ parse ();print_newline();
    loop()
  with End_of_file -> ()

let () = loop()