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

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