function main(input) {
  var args = input.split("");
  var arr = [];
  for (var i = 0; i < args.length - 2; i++) {
    arr[i] = args[i] + args[i + 1] + args[i + 2];
  }
  for (var i = 0; i < arr.length; i++) {
    arr[i] = parseInt(arr[i], 10);
  }

  var num = arr[0];
  for (var i = 0; i < arr.length; i++) {
    var res = Math.abs(num - 753);
    var res2 = Math.abs(arr[i] - 753);
    if (res > res2) {
      num = arr[i];
    }
  }
  console.log(Math.abs(num - 753));
}

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