program main
   implicit none
   integer:: i,j,k,minv=1000
   character*10 a
   read(*,*)a
   do i=1,len_trim(a)-2
      read(a(i:i+2),*)j
      if(abs(753-j)<=minv)minv=abs(j-753)
   enddo
   write(*,*)minv
end program main
