let s = stdin.ReadLine()

let a =
    [| for i in 0..s.Length - 3 -> s.[i..i + 2] |]
    |> Array.map int

[| for _ in 0..s.Length - 3 -> 753 |]
|> Array.map2 (-) a
|> Array.map abs
|> Array.min
|> printfn "%d"
