open Batteries

module IntSet = Set.Make (struct
  let compare = Pervasives.compare

  type t = int
end)

let read_two () = Scanf.sscanf (read_line ()) "%d %d" (fun a b -> (a, b))

let read_three () =
  Scanf.sscanf (read_line ()) "%d %d %d" (fun a b c -> (a, b, c))

let read_four () =
  Scanf.sscanf (read_line ()) "%d %d %d" (fun a b c d -> (a, b, c, d))

let read_list () =
  read_line () |> String.split_on_char ' '
  |> List.map (fun s -> int_of_string s)

let rec read_list_nl n =
  if n = 0 then [] else (read_line () |> int_of_string) :: read_list_nl (n - 1)

(* a**x *)
let pow a x =
  let rec aux acc = function 0 -> acc | n -> aux (acc * a) (n - 1) in
  aux 1 x

let rec pow2 n = if n mod 2 = 0 then 1 + pow2 (n / 2) else 0

let rec total acc = function [] -> acc | x :: rest -> total (acc + x) rest

let make_num s i = (s.(i) * 100) + (s.(i + 1) * 10) + s.(i + 2)

let () =
  let s =
    read_line () |> String.explode
    |> List.map (fun x -> int_of_char x - int_of_char '0')
    |> Array.of_list
  in
  let n = Array.length s in
  let ans = ref 1000 in
  for i = 0 to n - 3 do
    let x = make_num s i in
    ans := min (abs (753 - x)) !ans
  done;
  print_int !ans;
  print_newline ()
