function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.trim().split(" ");
	//input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var S = input;
  var output = 1000;
  for(var i = 0; i <= S.length - 3; i++){
    var tmp = parseInt(S.slice(i,i+3));
    output = Math.min(output,Math.abs(753 - tmp));
  }
  myout(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
