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

void main() {
    auto S = readln.chomp;
    iota(S.length-2).map!(i => S[i..i+3]).map!(s => abs(753-s.to!int)).reduce!min.writeln;
}

