program abc132a
  implicit none
  character(4) :: s
  integer :: i, m
  logical :: flag=.false.

  read(*,*) s

  if ((s(1:1) == s(2:2) .and. s(3:3) == s(4:4)) .and. s(2:2) == s(3:3)) then
    print *, 'No'
    stop
  endif

  if (s(1:1) == s(2:2) .and. s(3:3) == s(4:4)) then
    flag=.True.
  else if (s(1:1) == s(3:3) .and. s(2:2) == s(4:4)) then
    flag=.True.
  else if (s(1:1) == s(4:4) .and. s(2:2) == s(3:3)) then
    flag=.True.
  endif

  if (flag) then
    print *, 'Yes'
  else
    print *, 'No'
  endif

end program abc132a
