let rec seq a b = if a > b then [] else a :: seq (a+1) b
let it x = int_of_char x - 48
let () = Scanf.scanf "%s" @@ fun s ->
  let n = String.length s in
  seq 0 (n-3)
  |> List.map (fun i -> abs (100 * it s.[i] + 10 * it s.[i+1] + it s.[i+2] - 753))
  |> List.fold_left min 100000
  |> Printf.printf "%d\n"
