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 = a * 100 + b * 10 + c;
    gap = Math.abs((753 - num));
    if (!min || min >= gap) {
      min = gap;
    }
  }
  
  if (min === 0) {
    console.log('0');
  } else {
    console.log(min);
  }
}

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