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 a = readln();
    
    auto b = 99999999;
    foreach (i; 0 .. a.length - 2) {
        b = min( (a[i .. i+3].to!int - 753).abs, b);
    }
    writeln(b);    
}