program answer
  implicit none
  character(len=4) :: S
  read(*,*) S

  if(S(2:2)==S(1:1)) then
     if(S(3:3)==S(4:4).and.S(1:1)/=S(3:3)) then
	write(*,*) 'Yes'
        stop
     end if
  else if(S(3:3)==S(1:1).and.S(2:2)==S(4:4)) then
     write(*,*) 'Yes'
     stop
  else if(S(4:4)==S(1:1).and.S(2:2)==S(3:3)) then
     write(*,*) 'Yes'
     stop
  end if


  write(*,*) 'No'
  stop
end program answer