let S: String = readLine()!
var res: Int = 1000

var idxl: String.Index = S.startIndex
var idxr: String.Index = S.index(S.startIndex, offsetBy: 2)

while idxr < S.endIndex {
    res = min(res, abs(Int(S[idxl...idxr])! - 753))
    idxl = S.index(after: idxl)
    idxr = S.index(after: idxr)
}
print(res)