import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
 
void main() {
    auto a = readln();
    auto b = 99999999;
 
    foreach (i; 0 .. a.length - 2) {
        b = min((a[i .. i + 3].to!int - 753).abs, b);
    }
    writeln(b);
    writeln("");
}