from collections import Counter



Ss = eval(input())



num = len(set(Ss))

cnt = Counter(Ss)



if num == 2 and min(cnt.values()) == 2:

    print('Yes')

else:

    print('No')

Ss = list(input().rstrip())



Ss.sort()



if Ss[0]==Ss[1] and Ss[1]!=Ss[2] and Ss[2]==Ss[3]:

    print('Yes')

else:

    print('No')

from collections import Counter

Ss = eval(input())
num = len(set(Ss))
cnt = Counter(Ss)
if num == 2 and min(cnt.values()) == 2:
    print("Yes")
else:
    print("No")

Ss = list(input().rstrip())
Ss.sort()
if Ss[0] == Ss[1] and Ss[1] != Ss[2] and Ss[2] == Ss[3]:
    print("Yes")
else:
    print("No")

-from collections import Counter - -Ss = eval(input()) -num = len(set(Ss)) -cnt = Counter(Ss) -if num == 2 and min(cnt.values()) == 2: +Ss = list(input().rstrip()) +Ss.sort() +if Ss[0] == Ss[1] and Ss[1] != Ss[2] and Ss[2] == Ss[3]: