function main(input) {
  const S = input.split('');
  let min_gap;
  
  for (let i = 0; i < S.length -2; i++) {
    num = S[i] + S[i+1] + S[i+2];
    num = parseInt(num, 10);
    gap = Math.abs(753 - num);
    if (!min_gap || min_gap > gap) {
      min_gap = gap;
    }
  }
  
  console.log(min_gap);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));