implicit none
integer:: n, i, j, a, b, ans, t
integer,allocatable,dimension(:):: p
character(10) :: s

read(5,*) s
ans = 10000

!空白を除いた文字列の長さ分だけループする
do j=1, len_trim(s) - 2
    read (s(j:j+2),*) i
    ans = min(ans, abs(753 - i))  
enddo

write(6, *) ans

!read(5,*) n, a, b
!allocate(p(n))
!read(5,*) (p(i),i=1,n)


end