function Main(input) {
	var len = input.length;
	var min = 9999;
	for(var i = 0; i < len-2; i++) {
      var tmp = input.substr(i, 3);
      var v = parseInt(tmp, 10);
      var a = Math.abs(v-753);
      if (a < min) {
        min = a;
      }
	}
    console.log(min);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));