function Main(input) {

	var str  = input;
  var min = 753;
  var possib = 0;
  var anse = 0;
  for(var i = 0; i < str.length - 2 ; i++){
    var possib = parseInt(str[i] + "" +str[i+1]+ '' + str[i+2]);
    if(Math.abs(possib - 753) < min){
      min = Math.abs(possib - 753);
      anse = possib;
    }
  }
	console.log(min);
}

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