let () =
  let s = read_line () in
  Printf.printf "%d\n" @@
    Array.fold_right (fun s -> min @@ abs @@ int_of_string s - 753)
      (Array.init (String.length s - 2) (fun i -> String.sub s i 3)) max_int
