#!/bin/bash

read line
length=`echo ${#line}`

num=`expr $length - 2`

min=999

for i in `seq 1 $num`
do
 a=`echo $line | cut -b $i`
 b=`echo $line | cut -b $((i+1))`
 c=`echo $line | cut -b $((i+2))`
 diff=`expr 753 - $a$b$c`
 if [ $diff -ge 0 ] ; then
  if [ $diff -le $min ] ; then
   min=$diff
  fi
 else
  if [ $diff -ge $min ] ; then
   min=$diff
  fi
 fi
done

echo $min