function main(s){
    return s.split('').map((e,i,s)=> i<s.length-2 ? Math.abs((s[i]+s[i+1]+s[i+2])|0 -753) :1000).reduce((a,b) => a>b ? b : a);
}
console.log(main(require('fs').readFileSync('/dev/stdin','utf8')));