function main(arg) {
	arg = arg.split("\n")[0]
	arg = arg.split("")

	var near_n = -1
	var thresh = 753

	for (var i = 0;i < arg.length -2; i++) {
		var num = String(arg[i]) + String(arg[i+1]) + String(arg[i+2])
		num = Number(num)

		if (i === 0) {
			near_n = Math.abs(thresh - num)
			continue
		}

		var tmp = Math.abs(thresh - num)

		if (tmp < near_n) {
			near_n = tmp
		}
	}
	console.log(near_n)

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