You are given a 4-character string S consisting of uppercase English letters.
Determine if S consists of exactly two kinds of characters which both appear twice in S.

-----Constraints-----
 - The length of S is 4.
 - S consists of uppercase English letters.

-----Input-----
Input is given from Standard Input in the following format:
S

-----Output-----
If S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.

-----Sample Input-----
ASSA

-----Sample Output-----
Yes

S consists of A and S which both appear twice in S.

Difficulty: EASY

Solutions:
if len(set(map(str, input()))) == 2:
	print('Yes')
else:
	print('No')


s = list(input())
s = list(set(s))
if len(s) == 2:
	print('Yes')
else:
	print('No')


s = sorted(input())
print('Yes' if s[0] == s[1] and s[2] == s[3] and (s[1] != s[2]) else 'No')


s = sorted(input())
print('Yes' if s.count(s[0]) == 2 and s.count(s[2]) == 2 else 'No')


ans = dict()
for i in input():
	ans[i] = i
print('Yes' if len(ans) == 2 else 'No')


S = input()
S2 = set(S)
if len(S2) == 2:
	print('Yes')
	exit()
print('No')


s = input()
if len(set(s)) == 2 and s.count(s[0]) == 2:
	print('Yes')
else:
	print('No')


s = input()
ans = 'Yes'
for i in range(4):
	if s.count(s[i]) != 2:
		ans = 'No'
print(ans)


S = len(set(input()))
if S == 2:
	print('Yes')
else:
	print('No')


from collections import Counter
S = list(input())
S = Counter(S)
for i in list(S.values()):
	if i == 2 and len(S) == 2:
		ans = 'Yes'
	else:
		ans = 'No'
	break
print(ans)


import collections
s = input()
c = collections.Counter(s)
if list(c.values()) == [2, 2]:
	print('Yes')
else:
	print('No')


s = input()
S = []
for i in range(len(s)):
	S.append(s[i])
B = list(set(S))
cnt1 = 0
cnt2 = 0
if len(B) != 2:
	print('No')
else:
	for i in range(len(s)):
		if B[0] == s[i]:
			cnt1 += 1
		elif B[1] == s[i]:
			cnt2 += 1
	if cnt1 == 2 and cnt2 == 2:
		print('Yes')
	else:
		print('No')


s = input()
print('Yes') if len(s) == 4 and len(set(s)) == 2 else print('No')


S = {x for x in input()}
print('Yes' if len(S) == 2 else 'No')


S = input()
if S[0] == S[1] and S[2] == S[3] and (S[1] != S[2]) or (S[0] == S[2] and S[1] == S[3] and (S[0] != S[1])) or (S[0] == S[3] and S[1] == S[2] and (S[0] != S[1])):
	print('Yes')
else:
	print('No')


S = sorted(list(input()))
if S[0] == S[1] and S[2] == S[3] and (S[0] != S[2]):
	print('Yes')
else:
	print('No')


s = input()
cnt = set(s)
cnts = len(cnt)
if cnts == 2:
	print('Yes')
else:
	print('No')


s = input()
print(['No', 'Yes'][len(set(s)) == 2 and s.count(s[0]) == 2])


s = input()
sl = []
for i in s:
	if i not in sl:
		sl.append(i)
if len(sl) == 2:
	n = 0
	for i in s:
		if i == sl[0]:
			n += 1
	if n == 2:
		print('Yes')
else:
	print('No')


S = input()
c = 1
if S[0] == S[1]:
	if S[2] == S[3] and S[0] != S[2]:
		c = 0
elif S[0] == S[2]:
	if S[1] == S[3] and S[0] != S[1]:
		c = 0
elif S[0] == S[3]:
	if S[1] == S[2] and S[0] != S[1]:
		c = 0
if c:
	print('No')
else:
	print('Yes')


S = input()
print(['No', 'Yes'][all([S.count(s) == 2 for s in S])])


s = set(list(input()))
print('Yes' if s.__len__() == 2 else 'No')


n = input()
dic = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(26):
	if n.count(str(dic[i])) == 1 or n.count(str(dic[i])) == 3 or n.count(str(dic[i])) == 4:
		print('No')
		return
print('Yes')


s = str(input())
tmp = {}
for i in range(4):
	tmp.setdefault(s[i], 0)
	tmp[s[i]] += 1
if len(tmp) == 2 and max(tmp.values()) == 2:
	print('Yes')
else:
	print('No')


s = sorted(input())
if len(set(s)) == 2 and s[1] != s[2]:
	print('Yes')
else:
	print('No')


A = list(input())
print('Yes' if len(set(A)) == 2 & A.count(A[0]) == 2 else 'No')


S = input()
ans = 'Yes'
for s in S:
	if S.count(s) != 2:
		ans = 'No'
print(ans)


S = input()
s = set(S)
for c in s:
	if S.count(c) != 2:
		print('No')
		break
else:
	print('Yes')


S = input()
print('Yes' if all((S.count(s) == 2 for s in S)) else 'No')


s = input()
setslen = len(set(s))
if setslen == 2:
	print('Yes')
else:
	print('No')


s = input()
if len(''.join(set(s))) == 2:
	print('Yes')
else:
	print('No')


s = input()
s1 = set(s)
if len(s1) == 2:
	print('Yes')
else:
	print('No')


s = input()
a = s[0]
b = s[1]
c = s[2]
d = s[3]
if (a == b and c == d) and a != c or ((a == c and b == d) and a != b) or ((a == d and b == c) and a != b):
	print('Yes')
else:
	print('No')


a = list(input())
print('YNeos'[sum(map(a.count, a)) != 8::2])


S = sorted(input())
print('Yes' if S.count(S[0]) == 2 and S.count(S[2]) == 2 else 'No')


s = input()
print('NYoe s'[[s.count(i) == 2 for i in s] and len(set(s)) == 2::2])


from collections import defaultdict
S = defaultdict(int)
for i in input():
	S[i] += 1
if len(list(S.values())) == 2:
	(a, b) = list(S.values())
	if a == b == 2:
		print('Yes')
		return
print('No')


ans = 'No'
S = input()
initial = S[0]
SS = S.replace(initial, '')
if len(SS) == 2:
	if SS[0] == SS[1]:
		ans = 'Yes'
print(ans)


S = input()
S2 = list(set(S))
if len(set(S)) == 2 and S.count(S2[0]) == 2 and (S.count(S2[1]) == 2):
	print('Yes')
else:
	print('No')


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


st = input()
if len(set(st)) == 2:
	print('Yes')
else:
	print('No')


a = set(input())
if len(a) == 2:
	print('Yes')
else:
	print('No')


s = input()
print('Yes' if all([s.count(i) == 2 for i in set(s)]) else 'No')


s = input()
se = set(s)
print('Yes' if len(se) == 2 else 'No')


S = str(input())
hantei = 0
for i in range(len(S)):
	if S.count(S[i]) == 2:
		hantei += 1
if hantei == 4:
	print('Yes')
else:
	print('No')


S = input()
s = list(S)
if s[0] == s[1] and s[2] == s[3] and (s[0] != s[2]):
	print('Yes')
elif s[0] == s[2] and s[1] == s[3] and (s[0] != s[1]):
	print('Yes')
elif s[0] == s[3] and s[1] == s[2] and (s[0] != s[1]):
	print('Yes')
else:
	print('No')


print('YNeos'[len(set(input())) != 2::2])


S = str(input())
T = [S[0], S[1], S[2], S[3]]
T.sort()
if T[0] == T[1] and T[2] == T[3] and (T[1] != T[2]):
	print('Yes')
else:
	print('No')


S = input()
ary = list(set(S))
print('Yes' if len(ary) == 2 else 'No')


S = list(input())
T = set(S)
if len(T) == 2:
	print('Yes')
else:
	print('No')


s = input()
d = {}
for i in range(4):
	if s[i] not in d:
		d[s[i]] = 1
	else:
		d[s[i]] += 1
ans = 'Yes'
for i in d:
	if d[i] != 2:
		ans = 'No'
print(ans)


from collections import defaultdict
S = input()
dct = defaultdict(int)
for s in S:
	dct[s] += 1
for (key, val) in dct.items():
	if not val == 2:
		print('No')
		return
print('Yes')


if len(set([i for i in input()])) == 2:
	print('Yes')
else:
	print('No')


print(['No', 'Yes'][len(set(input())) == 2])


s = input()
print('YNeos'[any((s.count(c) != 2 for c in set(s)))::2])


(a, b, c, d) = sorted(input())
if a == b and c == d and (b != c):
	print('Yes')
else:
	print('No')


s = sorted(input())
print('Yes' if s[::2] == s[1::2] != s[::-2] else 'No')


s = str(input())
s = set(s)
if len(s) == 2:
	print('Yes')
else:
	print('No')


inputS = set(input())
if len(inputS) == 2:
	print('Yes')
else:
	print('No')


x = input()
y = len(set(x))
print('Yes' if y == 2 else 'No')


S = sorted(input())
if len(set(S)) == 2 and S[0] == S[1] and (S[1] != S[2]) and (S[2] == S[3]):
	print('Yes')
else:
	print('No')


s = input()
cou = []
enc = 0
enc1 = 0
for i in s:
	if i not in cou:
		cou.append(i)
if len(cou) != 2:
	print('No')
	return
for i in s:
	if i in cou[0]:
		enc += 1
	if i in cou[1]:
		enc1 += 1
if enc == 2 and enc1 == 2:
	print('Yes')
else:
	print('No')


s = list(input())
s.sort()
print('YNeos'[not s[0] == s[1] != s[2] == s[3]::2])


S = input()
L = {}
ans = 'Yes'
for s in S:
	if s in list(L.keys()):
		L[s] += 1
		if L[s] > 2:
			ans = 'No'
	else:
		L[s] = 1
if len(list(L.keys())) != 2:
	ans = 'No'
print(ans)


s = input()
d = dict()
for si in s:
	if si not in list(d.keys()):
		d[si] = 1
	else:
		d[si] += 1
if len(d) != 2:
	print('No')
	return
else:
	for v in list(d.values()):
		if v != 2:
			print('No')
			return
print('Yes')


def main():
	s = input()
	print('Yes' if len(set(s)) == 2 else 'No')
main()


(a, b, c, d) = sorted(input())
print(('No', 'Yes')[a == b != c == d])


s = list(input())
ans = 'No'
if len(list(set(s))) == 2:
	ans = 'Yes'
print(ans)


s = input()
o = 'Yes' if len(set(s)) == 2 else 'No'
print(o)


n = input()
print('Yes' if len(set(n)) == 2 else 'No')


S = input()
print('Yes' if all((S.count(S[i]) == 2 for i in range(4))) else 'No')


S = list(input())
S.sort()
print(['No', 'Yes'][S[0] == S[1] and S[2] == S[3] and (S[1] != S[2])])


import collections
S = input()
s = collections.Counter(S)
if len(s) == 2 and s.most_common()[0][1] == 2:
	print('Yes')
else:
	print('No')


def resolve():
	S = set(input())
	print('Yes' if len(S) == 2 else 'No')
resolve()


s = input()
for i in s:
	if s.count(i) != 2:
		print('No')
		return
print('Yes')


print('YNeos'[not (lambda s: s[0] == s[1] != s[2] == s[3])(sorted(input()))::2])


s = input()
S = sorted(s)
S.sort()
flag = False
if S[0] == S[1]:
	if S[2] == S[3]:
		if S[1] != S[2]:
			flag = True
if flag:
	print('Yes')
else:
	print('No')


S = list(input())
N = set(S)
if len(N) == 2:
	print('Yes')
else:
	print('No')


S = list(input())
A = len(set(S))
if A == 2:
	print('Yes')
else:
	print('No')


s = input()
a = 0
b = 0
c = 0
for i in range(1, 4):
	if ord(s[0]) == ord(s[i]):
		a = i
		b += 1
if b == 1:
	if a == 1:
		if ord(s[2]) == ord(s[3]):
			print('Yes')
		else:
			print('No')
	elif a == 2:
		if ord(s[1]) == ord(s[3]):
			print('Yes')
		else:
			print('No')
	elif a == 3:
		if ord(s[1]) == ord(s[2]):
			print('Yes')
		else:
			print('No')
else:
	print('No')


s = input()
ss = set(s)
if len(ss) == 2:
	print('Yes')
else:
	print('No')


C = set((s_i for s_i in input()))
print('Yes' if len(C) == 2 else 'No')


S = input()
set_S = set(S)
if len(set_S) != 2:
	print('No')
	return
cnt = 0
tmp = list(set_S)[0]
for s in S:
	if tmp == s:
		cnt += 1
if cnt != 2:
	print('No')
else:
	print('Yes')


a = list(input())
if len(a) > 4:
	stop()
a.sort()
if a[0] == a[1] and a[2] == a[3] and (a[0] != a[2]):
	print('Yes')
else:
	print('No')


s = input()
print('{}'.format('Yes' if len(set(s)) == 2 else 'No'))


S = list(input())
if len([x for x in set(S) if S.count(x) > 1]) == 2:
	print('Yes')
else:
	print('No')


S = list(input())
s = set(S)
lis = {}
for x in S:
	if x in lis:
		lis[x] += 1
	else:
		lis[x] = 1
ans = True
if len(lis) == 2:
	for x in s:
		if lis[x] != 2:
			ans = False
else:
	ans = False
if ans:
	print('Yes')
else:
	print('No')


S = list(input())
S.sort()
if S[0] == S[1]:
	if S[2] == S[3]:
		if S[0] != S[2]:
			print('Yes')
		else:
			print('No')
	else:
		print('No')
else:
	print('No')


print('YNeos'[len(''.join(set(sorted(input())))) != 2::2])


from collections import Counter
S = input()
c = Counter(S)
ans = 'No'
if len(c) == 2:
	if all([x for x in c.values() if x == 2]):
		ans = 'Yes'
print(ans)


s = input()
s1 = s[:2]
s2 = s[2:]
if s[0] == s[1] and s[0] == s[2] and (s[0] == s[3]):
	print('No')
elif s1[0] == s1[1]:
	if s2[0] == s2[1]:
		print('Yes')
	else:
		print('No')
elif s1[0] == s2[1]:
	if s1[1] == s2[0]:
		print('Yes')
	else:
		print('No')
elif s1[1] == s2[1]:
	if s1[0] == s2[0]:
		print('Yes')
	else:
		print('No')
else:
	print('No')


s = input()
print(['No', 'Yes'][all((s.count(s[i]) == 2 for i in range(4)))])


s = input()
print('Yes' if all(map(lambda c: s.count(c) == 2, s)) else 'No')


s = input()
for i in s:
	if s.count(i) != 2:
		print('No')
		exit()
print('Yes')


s = input()
x = len(set(s))
if x == 2:
	print('Yes')
else:
	print('No')


S = input()
s = []
for i in range(4):
	s.append(S[i])
s = set(s)
print('Yes' if len(s) == 2 else 'No')


S = input()
print('Yes' if sum([2 == S.count(ch) for ch in S]) == 4 else 'No')


word = input()
list_word = list(word)
if list_word.count(list_word[0]) == 2 and list_word.count(list_word[1]) == 2 and (list_word.count(list_word[2]) == 2):
	print('Yes')
else:
	print('No')


s = input()
s = s.replace(s[0], '')
print('Yes' if len(s) == 2 and s[0] == s[1] else 'No')


from _collections import defaultdict
S = input()
cnt = defaultdict(int)
for i in range(len(S)):
	cnt[S[i]] += 1
	if cnt[S[i]] > 2 or len(cnt) > 2:
		print('No')
		return
print('Yes')


s = input()
print('Yes' if 2 == s.count(s[0]) == s.count(s[1]) == s.count(s[2]) else 'No')


S = input()
a = len(list(set(S))) == 2
ans = 'Yes' if a else 'No'
print(ans)


S = list(input())
n = len(set(S))
print('Yes' if n == 2 and S.count(S[0]) == 2 else 'No')


from collections import Counter
a = Counter(input()).most_common()
if len(a) == 2:
	if a[1][1] == 2:
		print('Yes')
else:
	print('No')


S = input()
s = set(S)
print('NYoe s'[len(s) == 2 and S.count(list(s)[0]) == 2::2])


import collections
S = list(str(input()))
num = collections.Counter(S)
for (i, j) in num.items():
	if j != 2:
		print('No')
		return
print('Yes')


s = input()
for a in s:
	if s.count(a) != 2:
		print('No')
		break
else:
	print('Yes')


s = input()
l = {}
for i in s:
	l[i] = 1
if len(l) == 2:
	print('Yes')
else:
	print('No')


x = list(input())
a1 = x[0] == x[2] and x[1] == x[3]
a2 = x[0] == x[1] and x[2] == x[3]
a3 = x[0] == x[3] and x[1] == x[2]
b = len(set(x)) == 2
if b and (a1 or a2 or a3):
	print('Yes')
else:
	print('No')


def main():
	s = sorted(input())
	print('Yes' if s[0] == s[1] and s[2] == s[3] and (s[0] != s[3]) else 'No')

def __starting_point():
	main()
__starting_point()


import sys
S = list(sys.stdin.readline().strip())
S.sort()
if S[0] == S[1] and S[2] == S[3] and (S[0] != S[2]):
	print('Yes')
else:
	print('No')


S = input()
flag = False
if S[0] == S[1] and S[1] != S[2] and (S[2] == S[3]):
	flag = True
if S[0] == S[2] and S[2] != S[3] and (S[1] == S[3]):
	flag = True
if S[0] == S[3] and S[1] != S[3] and (S[1] == S[2]):
	flag = True
if flag:
	print('Yes')
else:
	print('No')


s = input()
n = s.count(s[0])
print('YNeos'[n != 2 or len(set(s)) != 2::2])


s = input()
l = {}
ans = 'Yes'
for i in s:
	if i not in l.keys():
		l[i] = 1
	else:
		l[i] += 1
for i in l.values():
	if i != 2:
		ans = 'No'
print(ans)


let = set(input())
print({True: 'Yes', False: 'No'}[len(let) == 2])


l = [x for x in input()]
l = set(l)
if 2 == len(l):
	print('Yes')
else:
	print('No')


s = input()
lst = []
for i in range(4):
	lst.append(s[i])
ans = 0
for i in range(4):
	if lst.count(lst[i]) != 2:
		ans = 1
if ans == 0:
	print('Yes')
else:
	print('No')


l = input()
l2 = set(l)
if len(l2) == 2:
	print('Yes')
else:
	print('No')


a = sorted(input())
if (len(set(a)) == 2) * (a[1] != a[2]):
	print('Yes')
else:
	print('No')


w = input()
s = list(set(list(w)))
print('YNeos'[len(s) != 2 or w.count(s[0]) != 2::2])


S = input()
S = list(set(S))
l = len(S)
if l == 2:
	print('Yes')
else:
	print('No')


s = input()
e = set(s)
if len(e) == 2:
	print('Yes')
else:
	print('No')


s = input()
for i in range(len(s)):
	if s.count(s[i]) != 2:
		print('No')
		break
else:
	print('Yes')


s = input()
sset = list(set(s))
print('Yes' if len(sset) == 2 and s.count(sset[0]) == s.count(sset[1]) == 2 else 'No')


S = input()
T = []
for i in S:
	if i not in T:
		T.append(i)
if len(T) == 2 and S.count(T[0]) == 2 and (S.count(T[1]) == 2):
	print('Yes')
else:
	print('No')


(a, b, c, d) = sorted(input())
print('YNeos'[1 - (a == b != c == d)::2])


s = input()
print('YNeos'[any((s.count(t) != 2 for t in s))::2])


import collections
s = input()
c = collections.Counter(list(s))
print('Yes' if len(c.keys()) == 2 and len(set(c.values())) == 1 else 'No')


S = list(input())
S_ = list(set(S))
if len(S_) == 2:
	cnt = 0
	for s_ in S_:
		for i in range(4):
			if S[i] == s_:
				cnt += 1
		if cnt == 2:
			cnt = 0
			continue
		else:
			print('No')
			return
	print('Yes')
else:
	print('No')


s = input()
S = set(s)
if len(S) != 2:
	print('No')
	return
else:
	for i in range(4):
		if s.count(s[i]) != 2:
			print('No')
			return
print('Yes')


S = list(input())
ans = 'No'
if S[0] == S[1] and S[0] != S[2] and (S[2] == S[3]) or (S[0] == S[2] and S[0] != S[1] and (S[1] == S[3])) or (S[0] == S[3] and S[0] != S[1] and (S[1] == S[2])):
	ans = 'Yes'
print(ans)


a = list(input())
print('YNeos'[sum([a.count(i) for i in a]) != 8::2])


s = input()
l = len(set(s))
if l == 2:
	print('Yes')
else:
	print('No')