void main() {
    string s = readln.chomp;
    int diff = 1000;
    foreach (i; 2 .. s.length) {
        int x;
        foreach_reverse (j; 0 .. 3) {
            x += (s[i-j] - '0') * 10 ^^ j;
        }
        diff = min(diff, abs(x-753));
    }
    diff.writeln;
}

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