implicit none
integer,parameter :: favorite = 753
integer :: n,k,m,i
character(10) :: s
read *,s
n = len_trim(s)
m = 999
do i = 1, n-3+1
   read(s(i:i+2),*) k
   k = abs(k - favorite)
   if (k < m) then
      m = k
   endif
enddo
print '(i0)',m
end