import Foundation

let s = readLine()!
var ans = 999
for i in 0..<s.count-2 {
  let from = s.index(s.startIndex, offsetBy: i)
  let to = s.index(from, offsetBy: 2)
  let sub = String(s[from...to])
  ans = min(ans, abs(753 - Int(sub)!))
}
print(ans)