let s = read_line ();;

let rec f i min_diff =
    let min_diff = min min_diff (abs ((int_of_string (String.sub s i 3)) - 753)) in
    if (String.length s) = (i + 3) then
        min_diff
    else (
        let min_diff = min min_diff (abs ((int_of_string (String.sub s i 4)) - 753)) in
        f (i+1) min_diff
    )
;;

print_endline (string_of_int (f 0 999999))
