program ABC114B
    implicit none
    integer(8)::i,N
    integer(8)::X
    integer(8)::diff_min
    character(10)::S

    read(5,*)S
    N=len_trim(S)

    do i=1,N-2
        read(S(i:i+2),*)X
        if(i==1 .or. abs(X-753)<diff_min)then
            diff_min=abs(X-753)
        end if
    end do

    print'(i0)',diff_min
end program ABC114B