var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	var s = toIntArr(input[0].split(''));
	var l = s.length;
	var ans = 100000;
	var x = 0;
	for(var i = 0; i < l-2; i++){
		x = s[i]*100 + s[i+1]*10 + s[i+2];
		x = abs(x - 753);
		if(ans > x) ans = x;
	}
	if(ans == 0) ans = 0;
	
	console.log(ans);
}