import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
	auto S = readln.split[0];
	int result = 10000;
	foreach (i; 0 .. S.length-2) { result = min( (S[i .. i+3].to!int - 753).abs, result); }
	result.writeln;
}
