program main
implicit None
	character*10::s
	integer::i,k,a,b,c
	
	read *,s
	
	k = len_trim(s)
	
	do i  = 1,k-2
		read(s(i:i),*) a
		b = a * 100
		read(s(i+1:i+1),*) a
		b = b + a * 10
		read(s(i+2:i+2),*) a
		b = b + a
		a = abs(b - 753)
		
		if(i == 1) c = a
		if(c > a) c = a
	enddo
	
	print 101,c
	
101 format(i0)
end program main