program atcoder
    implicit none
    character(30) s
    integer ans,k,i,l
    read(*,*)s
    l = len_trim(s)
    ans = 100000000
    do i=1,l-2
        read(s(i:i+2),*)k
        ans = min(ans,abs(753-k))
    enddo
    write(*,'(I0)')ans
!----------------------functions--------------------------
contains



end program atcoder