let cs = stdin.ReadLine().ToCharArray()
let N = Array.length cs

[0..N-3]
|> List.map (fun i -> 
  sprintf "%c%c%c" cs.[i] cs.[i+1] cs.[i+2]
  |> int
  |> fun n -> abs (n - 753) )
|> List.min
|> printfn "%d"
