function main(input) {
  const S = input.split('');
  let min;
  
  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(num - 753);
    if (!min || min > gap) {
      min = gap;
    }
  }
  
  console.log(min);
}

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