function abs() {
    echo $(($1>0?$1:-$1))
}
function min() {
    echo $(($1>$2?$2:$1))
}

read x
ans=753
for((i=0;i<${#x}-2;++i))
do
    t=`abs $((${x:i:3} - 753))`
    ans=`min $ans $t`
done
echo $ans
