const main = stdin => {
  const input = stdin.trim().split('\n')
  const S = input[0]

  let ans = 99999999
  for (let i = 0; i < S.length - 2; i++) {
    ans = Math.min(Math.abs(parseInt(S.substr(i, 3)) - 753), ans)
  }

  console.log(ans)
}
// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))
