i=require('fs').readFileSync('/dev/stdin','utf8');
i.includes('753')&&console.log(0);
if(!i.includes('753')){m=Infinity;i.split('').map((x,y)=>{if(y<i.length-2){s=i.substr(y,3);Math.abs(753-s)<m&&(m=Math.abs(753-s));}});console.log(m)}