program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n(ichar('0'):ichar('9'))=0,i
    character(4):: s
 
    read*, s
 
    if (s(2:2)==s(3:3)) then
        if (s(1:1)==s(2:2) .or. s(3:3)==s(4:4)) then
            print'(a)', 'Yes'
        else
            print'(a)', 'No'
        end if
    else
        print'(a)', 'No'
    end if
    
    
 
end program main