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

    console.log(min);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
