program aaa
implicit none

character :: one, two, three, four
character(4) :: s

read*, s

one=s(1:1)
two=s(2:2)
three=s(3:3)
four=s(4:4)

if(one==two.and.three==four) then
write(*,'(a3)') 'Yes'
else if(one==three.and.two==four) then
write(*,'(a3)') 'Yes'
else if(one==four.and.two==three) then
write(*,'(a3)') 'Yes'
else 
write(*,'(a2)') 'No'
end if
end program