Imports System
Module Module1

    Sub Main()
        Dim str = Console.ReadLine().Replace(vbNewLine, "")

        Dim len = str.Length

        Dim min = 10000000
        For index = 0 To len - 3
            min = Math.Min(Math.Abs(753 - Integer.Parse(str.Substring(index, 3))), min)
        Next

        Console.WriteLine(min)

        Return
    End Sub

End Module
