character(4) :: s
read *,s
if ((s(1:1) == s(2:2) .and. s(1:1) /= s(3:3) .and. s(3:3) == s(4:4)) .or.&
    (s(1:1) /= s(2:2) .and. s(1:1) == s(3:3) .and. s(2:2) == s(4:4)) .or.&
    (s(1:1) == s(4:4) .and. s(1:1) /= s(2:2) .and. s(2:2) == s(3:3))) then
print '(a)','Yes'
else
print '(a)','No'
endif
end