program ABC_079_A_GoodInteger
   implicit none
   character(4) N
   read(*, *) N
   if((N(2:2) == N(1:1) .and. N(2:2) == N(3:3)) .or. (N(3:3) == N(2:2) .and. N(3:3) == N(4:4))) then
       write(*, *) 'Yes'
   else
       write(*, *) 'No'
   end if
end program ABC_079_A_GoodInteger