function main(input) {
  var N = input[0];
  var base = 753;
  var ans = 753;
  for(var i=0;i<N.length-3;i++){
    ans = Math.min(ans, Math.abs(base - (Number(N.substr(i,i+2)) ) );
  }
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))
