program fa
  implicit none
  integer ::i,j
  character(len=4) :: S

  read(*,*) S

  if((S(1:1).eq.S(2:2)).and.(S(3:3).eq.S(4:4)).and.(S(2:2).ne.S(3:3))) then
  write(*,'(a)') 'Yes'
  elseif((S(3:3).eq.S(2:2)).and.(S(3:3).ne.S(4:4)).and.(S(1:1).eq.S(4:4))) then
  write(*,'(a)') 'Yes'
  elseif((S(4:4).eq.S(2:2)).and.(S(3:3).ne.S(4:4)).and.(S(1:1).eq.S(3:3))) then
  write(*,'(a)') 'Yes'
  else
  write(*,'(a)') 'No'
  endif



end program fa