program abc079a
  implicit none
  integer n

  read *, n
  if (mod(n, 1110) < 10 .or. mod(mod(n, 1000), 111) == 0) then
     print '(a)', 'Yes'
  else
     print '(a)', 'No'
  end if
end program abc079a
