const main = x => {
    s = x[0];
    var i, ans=0, value;
    for(i=0; i<s.length-2; i++) {
        value = Math.abs(753-parseInt(s.slice(i,i+3)));
        ans = ans?Math.min(ans, value):value;
    }
    console.log(ans);
    
};
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));