function main(input) {
    const args = input.split(" ");
    const No = args[0].split("");

    var Number;
    var ans = 753;

    for (var i = 0; i < parseInt(No.length - 2); i++) {
        Number = No.slice(i, i + 3).map(str => parseInt(str, 10));
        var new_ans = Number[0] * 100 + Number[1] * 10 + Number[2];
        if (Math.abs(753 - new_ans) < ans) {
            ans = Math.abs(753 - new_ans);
        }
    }
    console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));