program nanagoyon
  implicit none
  character(10) :: s
  integer :: i, x, d = 1e9
  read(*,*) s
  do i = 1, len_trim(s)-2
    read(s(i:i+2),*) x
    if (d > abs(x-753)) d = abs(x-753)
  end do
  write(*,'(i0)') d
end program nanagoyon