'use strict'

const n = 753

function main(input) {
  let nums = input.split('').map(v => ~~v)
  let ans = Number.MAX_SAFE_INTEGER

  for (let i = 0; i < nums.length - 2; i++) {
    let tmp = Math.abs(n - (nums[i] * 100 + nums[i + 1] * 10 + nums[i + 2]))
    ans = Math.min(tmp, ans)
  }

  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
