function Main(input) {
    var S = input.split("\n")[0];
    var len = S.length;
    var min = Number.MAX_VALUE;
    for (var n = 0; n < len - 3 + 1; n++) {
        var x = S.substr(n, 3) - 0;
        min = Math.min(min, Math.abs(753 - x));
    }

    console.log(min);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
