function main(input){
    var lines = input;
    var flg = true;
    var p=0;
    var ans = 0;
    var min=999;
    while(flg){
        var suu = Number(""+lines[p]+lines[p+1]+lines[p+2]);
        var mi = 753-suu;
        if(mi==0){
            min=0;
            break;
        }else if(mi<0){
            mi*=-1;
        }
        if(min>mi){
            min=mi;
        }
        p++;
        var t=p+2;
        if(t>lines.length){
            break;
        }
    }

    console.log(min);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));