function main(input) {
  const s = input.trim()
  const l = s.length
 
  let answer = 999
  
  for (let i = 0; i + 3 <= l; i++) {
    const t = Math.abs(parseInt(s.substring(i, i + 3), 10) - 753)
    if (t < answer) {
      answer = t
    }
  }
  console.log(answer)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))