let s = read_line ()
let ans = ref max_int
let f i = Char.code s.[i] - 48
let _ =
  for i = 0 to String.length s - 3 do ans := min !ans @@ abs @@ f i * 100 + f (i + 1) * 10 + f (i + 2) - 753 done;
  Printf.printf "%d\n" !ans