program prob1
    implicit none
    integer::n, i
    character(len=4)::s
    read(*,*) s
    do i = 1, 2
        read(s(i:i+2),*) n
        if(mod(n,111) == 0) then
            write(*,'(a)') "Yes"
            stop
        end if
    end do
    write(*,'(a)') "No"
    stop
end program