program main
	implicit none
	integer :: i, temp, ans
	character(10) :: S
	read(*, *) S
	ans = 100000
	do i = 1, len_trim(S)-2
		read(S(i:i+2), *) temp
		ans = min(ans,abs(temp-753))
	end do
	write(*, *) ans
end program main