Problem:
 Score : 100 points    Problem Statement 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 1 ASSA      Sample Output 1 Yes  S consists of A and S which both appear twice in S .       Sample Input 2 STOP      Sample Output 2 No       Sample Input 3 FFEE      Sample Output 3 Yes       Sample Input 4 FREE      Sample Output 4 No

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

    s = input().rstrip()
    a = list(set(s))
    if len(a) <2:
        print('No')
        exit()
    if s.count(a[0]) == s.count(a[1]) == 2:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Solution (Python):

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

Solution (Python):
s=input()
x=s.count(s[0])
y=s.count(s[1])
z=s.count(s[2])
if x==2 and y==2 and z==2:
  print("Yes")
else:
  print("No")

Solution (Python):
S=str(input())
if S[0]==S[1] and S[1]!=S[2] and S[2]==S[3]:
      print("Yes")
elif S[0]==S[2] and S[0]!=S[1] and S[1]==S[3]:
     print("Yes")
elif S[0]==S[3] and S[0]!=S[1] and S[1]==S[2]:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter

c = Counter(input())

ok = True
for k in c:
    if c[k] != 2:
        ok = False
        break

if ok:
    print('Yes')
else:
    print('No')

Solution (Python):
S = input()
cnt = 0
for i in range(len(S)-1):
    for j in range(i+1, len(S)):
        if S[i] == S[j]:
            cnt += 1

if cnt == 2:
    print("Yes")

else:
    print("No")

Solution (Python):
s = list(input())
if len(set(s)) == 2:
    for i in set(s):
        if s.count(i) == 2:
            pass
        else:
            print("No") 
            exit()
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
s = set(S)
cnt = 0

if len(s) != 2:
  print("No")
  exit()
for i in range(4):
  if S[0] == S[i]:
    cnt += 1
if cnt == 2:
  print("Yes")
else:
  print("No")

Solution (Python):
S = input()

if len(set(S)) == 2:
  if S.count(S[0]) == 2:
    print("Yes")
else:
  print("No")

Solution (Python):
s=input()

if s[0]==s[1] and s[0]==s[2] and s[0]==s[3]:
    print("No")
elif(s[0]==s[2] and s[1]==s[3]) or (s[0]==s[1] and s[2]==s[3]) or (s[0]==s[3] and s[1]==s[2]):
    print("Yes")
else:
    print("No")

Solution (Python):
S=input()
data=[S[i] for i in range(0,4)]
data.sort()
if data[0]==data[1]:
    if data[1]!=data[2] and data[2]==data[3]:
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
N = int(input())
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

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

Solution (Python):

import collections

S = list(input())

c = collections.Counter(S)

check_1 = int(c.most_common()[0][1])
if (check_1 == 2):
  pass
else:
  print("No")
  exit()

check_2 = int(c.most_common()[1][1])
if (check_2 == 2):
  print("Yes")
else:
  print("No")
  exit()

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    s = S()
    b = list(set(s))
    a = len(list(set(s)))
    if a == 2 and s.count(b[0]) == s.count(b[1]) == 2:
        print("Yes")
    else:
        print("No")
    return


def B():
    n = II()
    p = LI()
    ans = 0
    for i in range(1,n-1):
        if (p[i - 1] < p[i] and p[i] < p[i + 1]) or (p[i + 1] < p[i] and p[i] < p[i - 1]):
            ans += 1
    print(ans)
    return


def C():
    n = II()
    d = LI()
    d.sort()
    ans = 0
    for i in range(10**5+1):
        if n // 2 == bisect_left(d, i):
            ans += 1
    print(ans)
    return


def combination_mod(n, k, mod):
    
    

    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    a = factorial(n) % mod
    b = factorial(k) % mod
    c = factorial(n - k) % mod
    return (a * power_func(b, mod - 2, mod) * power_func(c, mod - 2, mod)) % mod
    
def power_func(a, b, mod):
    
    

    if b == 0: return 1
    if b % 2 == 0:
        d = power_func(a, b // 2, mod)
        return d * d % mod
    if b % 2 == 1:
        return (a * power_func(a, b - 1, mod)) % mod


def D():
    n, k = LI()
    ans = 0
    for i in range(1,k+1):
        a = combination_mod(n - k + 1, i, mod)
        b = combination_mod(k - 1, i - 1, mod)
        print((a*b)%mod)
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    A()

Solution (Python):
s = input()

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

if len(set(S)) == 2 and S.count(S[0])==2:
	print("Yes")
else:
	print("No")

Solution (Python):
S = sorted(input())

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

Solution (Python):
S = input()
l = list()
for a in S:
    l.append(a)

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

Solution (Python):
s = input()
a = s[0]
b = s[1]
c = s[2]
d = s[3]
if a==b:
    if c==d:
        if a!=c: print("Yes")
        else: print("No")
    else: print("No")
elif a==d:
    if b==c: print("Yes")
    else: print("No")
elif a==c:
    if b==d: print("Yes")
    else: print("No")
else: print("No")

Solution (Python):
S = str(input())

a = S[0]
b = S[1]
c = S[2]
d = S[3]

acount = 0
bcount = 0
ccount = 0
dcount = 0

if S.count(a) == 2 and S.count(c) == 2 and S.count(b) == 2 and S.count(d) == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
ans = False
if S[0] == S[1]:
    ans = (S[0] != S[2] and S[2] == S[3])
elif S[0] == S[2]:
    ans = (S[0] != S[1] and S[1] == S[3])
elif S[0] == S[3]:
    ans = (S[0] != S[1] and S[1] == S[2])
print("Yes" if ans else "No")

Solution (Python):
S = input()
A = 'Yes'
for i in range(4):
    C = S.count(S[i])
    if C != 2:
        A = 'No'
        
print(A)

Solution (Python):
S = input()

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

Solution (Python):
s= input()

s=sorted(s)

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

Solution (Python):
S = input()
S = sorted(S)

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

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

Solution (Python):
S = input()
S = sorted(S)
num = len(set(S))

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

Solution (Python):
import collections
N = list(input())
N = list(collections.Counter(N).values())
if N[0] == 2 and N[1] == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
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")

Solution (Python):
s = input()
s = sorted(s)

if s[0] == s[1] and s[1] != s[2] and s[2] == s[3]:
    print("Yes")
else:
    print("No")

Solution (Python):
s = str(input())

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

Solution (Python):
a = input()
y =0
a=sorted(a)
for i in range(4):
    x = a.count('{}'.format(a[i]))
    if x!=2:
        print("No")
        y=1
        break
if y==0:print("Yes")

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

Solution (Python):
s = input()
s = s.lower()
sset = set(s)
judge = False
for i in s:
    if s.count(i) == 2:
        judge = True
    else:
        judge = False
if len(sset) != 2:
    judge = False
print('Yes' if judge else 'No')

Solution (Python):
S = input()
for s in S:
  if S.count(s) == 2:
    continue
  else:
    print('No')
    break
else:
  print('Yes')

Solution (Python):
S = input()

if len(set(S)) == 2:
    for x in set(S):
        if S.count(x) == 2:
            continue
        else:
            print('No')
            break
    else:
        print('Yes')
else:
    print('No')

Solution (Python):



def MI():return map(int,input().split())
def LI():return list(MI())

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

Solution (Python):
A=input()
if A[0]==A[1]==A[2]==A[3]:
  print("No")
elif (A[0]==A[1] and A[2]==A[3]) or (A[1]==A[2] and A[0]==A[3]) or (A[0]==A[2] and A[1]==A[3]):
  print("Yes")

else:
  print("No")

Solution (Python):
A=input()
if A[0]==A[1]==A[2]==A[3]:
  print("No")
elif A[0]==A[1] and A[2]==A[3]:
  print("Yes")
elif A[1]==A[2] and A[0]==A[3]:
  print("Yes")
elif A[0]==A[2] and A[1]==A[3]:
  print("Yes")
else:
  print("No")

Solution (Python):
S = input()
if len(set(S)) == 2:
  if S.count(S[0]) == 2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Solution (Python):
S = input()
A = S[0]
B = S[1]
C = S[2]
D = S[3]

if A == B and C ==D and A != C:
  print("Yes")
elif A == C and B ==D and A != B:
  print("Yes")
elif A == D and B == C and A != B:
  print("Yes")
else:
  print("No")

Solution (Python):
from collections import Counter
s = input()
s = dict(Counter(s))
if len(s)==2 and (v==2 for v in list(s.values())):
  print('Yes')
  exit()
print('No')

Solution (Python):
s = list(input())
if len(set(s))==2 and ((s[0]==s[1] and s[2]==s[3]) or (s[0]==s[2] and s[1]==s[3]) or (s[0]==s[3] and s[1]==s[2])):
  print('Yes')
else:
  print('No')

Solution (Python):
str = input()
strlist = list(str)
strlist.sort()

if strlist[0] == strlist[1] and strlist[2] == strlist[3] and strlist[0] != strlist[3]:
  print("Yes")
else:
  print("No")

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

Solution (Python):
s = input()
variety = set(s)
if len(variety) == 2:
    x = []
    for i in variety:
        x.append(i)
    count_1 = s.count(x[0])
    count_2 = s.count(x[1])
    if count_1 == count_2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
s=input()
if len(set(s))==2:
    print("Yes")
else:print("No")

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

Solution (Python):
icase=0
if icase==0:
    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")

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

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

Solution (Python):
S = set(list(input()))
print("Yes" if len(S)==2 else "No")

Solution (Python):
a = input()

if a[0] == a[1] == a[2] == a[3]:
    print("No")
elif a[0] == a[1] and a[2] == a[3]:
    print("Yes")
elif a[0] == a[2] and a[1] == a[3]:
    print("Yes")
elif a[0] == a[3] and a[1] == a[2]:
    print("Yes")
else:
    print("No")

Solution (Python):
s=input()

m=list(s)

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

Solution (Python):
S = input()
A = S[0]
B = S[1]
C = S[2]
D = S[3]
if A == B and C == D and A != C:
  print('Yes')
elif A == C and B == D and A != B:
  print('Yes')
elif A == D and B == C and A != B:
  print('Yes')
else:
  print('No')

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

Solution (Python):
s = input()

s = sorted(s)
s = ''.join(s)

if s[0] == s[1] and s[2] == s[3] and s[2] != s[1]:
    print("Yes")
else:
    print("No")

Solution (Python):
s=sorted(input())
if s[0]==s[1]!=s[2]==s[3]:print('Yes')
else:print("No")

Solution (Python):
s = input()
a = set(s)
if len(a) != 2:
  print('No')
  exit()
  
import collections
c = collections.Counter(s)
if c.most_common()[0][1] == 2:
  print('Yes')
else:
  print('No')

Solution (Python):
S=input()
if len(set(S))==2:
    T=sorted(list(S))
    if T[0]==T[1] and T[2]==T[3]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
import sys
input = sys.stdin.readline
S = list(input())[: -1]
for i in range(4):
  if S.count(S[i]) != 2:
    print("No")
    exit(0)
print("Yes")

Solution (Python):
import collections
s = str(input())
l = []
for i in range(0,4):
  l.append(s[i])
  i += 1
c = collections.Counter(l)

if len(c) == 2:
  print('Yes')
else:
  print('No')

Solution (Python):
S = input()
s = list(set(S))
print("Yes" if len(s) == 2 and S.count(s[0]) == S.count(s[1]) == 2 else "No")

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

Solution (Python):
l = input()
if len(set(l)) == 2:
  if l.count(l[0]) == 2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

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

Solution (Python):
S = str(input())
S = sorted(S)
if S.count(S[0]) == 2 and S.count(S[2]) == 2:
  print("Yes")
else:
  print("No")

Solution (Python):
S=input()
a=S[0]
flag=False
b=""
for i in range(4):
  if(S[i]!=a and b==""):
    flag=True
    b=S[i]
  if(S[i]!=a and S[i]!=b and flag==True):
    print("No")
    exit()
if(flag):
  print("Yes")
else:
  print("No")

Solution (Python):
a,b,c,d = input()
listo = [a,b,c,d]
listo.sort()
if (listo[0]==listo[1])and(listo[1]!=listo[2])and(listo[2]==listo[3]) : print("Yes")
else : print("No")

Solution (Python):
import sys
s = str(input())
a = {i for i in s}
ans = 0
if len(a) == 2:
     for i in range(1,4):
          if s[0] == s[i]:
               ans += 1
     if ans == 1:
          print('Yes')
          sys.exit()
print('No')

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

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

Solution (Python):
N=input()
A=len(set(N))
if A==2 and N.count(N[0]) == N.count(N[1]) == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
S=set(input())
print("Yes" if len(S)==2 else "No")

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

Solution (Python):
import collections

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

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

Solution (Python):
S=input()

if(S[0]==S[1]==S[2]==S[3]):
    print("No")

elif(S[0]==S[1] and S[2]==S[3]):
    print("Yes")

elif(S[0]==S[2] and S[1]==S[3]):
    print("Yes")

elif(S[0]==S[3] and S[1]==S[2]):
    print("Yes")

else:
    print("No")

Solution (Python):
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    print('Yes' if len(set(S)) == 2 and all([S.count(s) == 2 for s in set(S)]) else 'No')


if __name__ == '__main__':
    main()

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

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

Solution (Python):
import sys


def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

def LI(): return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number): return [LI() for _ in range(rows_number)]

p2D = lambda x: print(*x, sep="\n")


s=input()

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

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

Solution (Python):
s = input()

dic = {}
for ch in s:
  if ch not in dic:
    dic[ch] = 1
  else:
    dic[ch] += 1
    
if len(dic)==2 and (dic[ch]==2 for ch in dic):
  print('Yes')
else:
  print('No')

Solution (Python):
S = input()
s = list(set(S))
print("Yes" if len(s) == 2 and S.count(s[0]) == S.count(s[1]) == 2 else "No")

Solution (Python):
S = input()
L = []

for i in range(4):
  T = "n"
  for j in range(len(L)):
    if S[i] == L[j][0]:
      L[j][1] +=1
      T = "y"
  if T == "n":
    L.append([S[i],1])
    
if len(L) == 2:
  if L[0][1] == L[1][1]:
    print("Yes")
  else:
    print("No")
else:
  print("No")

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

Solution (Python):
S = input()
ans = 'No'
if len(set(S)) == 2:
    if S.count(list(set(S))[0]) == S.count(list(set(S))[1]):
        ans = 'Yes'
print(ans)

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

Solution (Python):
S = input()
ans = str()

if S[0] == S[1]:
  if S[0] != S[2] and S[2] == S[3]:
    ans = "Yes"
  else :
    ans = "No"

else :
  if S[0] == S[2] and S[1] == S[3]:
    ans = "Yes"
  elif S[0] == S[3] and S[1] == S[2]:
    ans = "Yes"
  else:
    ans = "No"
  
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
import math
import collections
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

s=input()
letter=[]
for i in range(4):
    letter.append(s[i:i+1])

i=collections.Counter(letter)

mul=1
for l in i:
    if i[l]==2:
        continue
    else:
        print("No")
        sys.exit()
print("Yes")

Solution (Python):
S = input()
print("Yes" if len(set(S))==2 and S.count(S[0])==2 else "No")

Solution (Python):
s = input()

cnt = 0
for i in range(len(s) - 1):
    for j in range(i + 1, len(s)):
        if s[i] == s[j]:
            cnt += 1

if cnt == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
S = list(input())
S.sort()

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

Solution (Python):
s = list(input())

s.sort()

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

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

Solution (Python):
s = set(input())

if len(s) == 2:
    print("Yes")
else :
    print("No")

Solution (Python):
S = input()

T = sorted(S)
ans = (
    'Yes' if T[0] == T[1] and T[1] != T[2] and T[2] == T[3] else
    'No'
)

print(ans)

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

Solution (Python):
S = input()
s = list(set(S))
print("Yes" if len(s) == 2 and S.count(s[0]) == S.count(s[1]) == 2 else "No")

Solution (Python):
from collections import defaultdict

S = input()
S =list(S)

dic = defaultdict(int)
for i in S:
    dic[i] += 1

dic = dict(dic)
bools = [i == 2 for i in dic.values()]
if all(bools):
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import Counter
s = input().rstrip()
c = Counter(list(s))
if len(c) == 2 and c.most_common()[0][1] == 2:
    print('Yes')
else:
    print('No')

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

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

Solution (Python):
s=sorted(input())
if s[0]==s[1] and s[2]==s[3] and s[1]!=s[2]:print("Yes")
else:print("No")

Solution (Python):
S = input()

table = {}
for s in S:
    table[s] = 1 if table.get(s) is None else table.get(s) + 1

answer = 'Yes' if all([value is 2 for value in table.values()]) else 'No'

print(answer)

Solution (Python):
S = input()
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[3]:
    print('Yes')
elif S[0] == S[3] and S[1] == S[2] and S[0] != S[2]:
    print('Yes')
else:
    print('No')

Solution (Python):
s = list(input())
t = list(set(s))
if len(t) == 2 and s.count(t[0]) == 2 :
    print("Yes")
else :
    print("No")

Solution (Python):
S=list(map(str,input()))
S.sort()
if S[0]==S[1] and S[2]==S[3] and S[0]!=S[2]:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()
if s.count(s[0])== 2 and s.count(s[1])== 2 and s.count(s[2])== 2 and s.count(s[3])== 2:
  print("Yes")
else:
  print("No")

Solution (Python):
S = input()

d = {}
for s in S:
  if s in d.keys():
    d[s] += 1
  else:
    d[s] = 1 

print("Yes" if list(d.values()) == [2,  2] else "No")

Solution (Python):
s = input()
judge = False
if s[0] == s[1]:
  if s[2] == s[3]:
    if s[0] != s[2]:
      judge = True
if s[0] == s[2]:
  if s[1] == s[3]:
    if s[0] != s[1]:
      judge = True
if s[0] == s[3]:
  if s[2] == s[1]:
    if s[0] != s[2]:
      judge = True
      
if judge:
  print("Yes")
else:
  print("No")

Solution (Python):
S = input()
s = set(S)
if (len(s) == 2):
    print("Yes")
else:
    print("No")

Solution (Python):
s=input()
print("Yes" if ((s[0]==s[1]!=s[2] and s[2]==s[3]) or
   (s[0]==s[2]!=s[1] and s[1]==s[3]) or
   (s[0]==s[3]!=s[1] and s[1]==s[2])) else "No")

Solution (Python):
s=input()
chk={}
for i in range(4):
  if s[i] in chk:
    chk[s[i]]+=1
  else:
    chk[s[i]]=1
print("Yes" if len(chk)==2 and chk[s[0]]==2 else "No")

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

Solution (Python):
def q1():
    S = list(input())
    if S.count(S[0]) == 2 and S.count(S[1]) == 2 and S.count(S[2]) == 2 and S.count(S[3]) == 2:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    q1()

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

Solution (Python):
s = input()
if len(set(s))==2:
    if len(s.replace(s[0], ''))==2:
        print('Yes')
else:
    print('No')

Solution (Python):
s = input()
s1 = ord(s[0])
s2 = ord(s[1])
s3 = ord(s[2])
s4 = ord(s[3])

if s1 == s2:
    if s3 == s4 and s1 != s3:
        print("Yes")
        exit()
elif s1 == s3:
    if s2 == s4 and s1 != s2:
        print("Yes")
        exit()
elif s1 == s4:
    if s2 == s3 and s1 != s2:
        print("Yes")
        exit()

print("No")

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

Solution (Python):
s = str(input())
x = {}
for i in range(4):
  if s[i] not in x.keys():
    x[s[i]] = 1
  else:
    x[s[i]] += 1
for i in x.values():
  if i != 2:
    print("No")
    exit()
print("Yes")

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

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

Solution (Python):
s = input()
if s[0]==s[1] and s[0]!=s[2] and s[2]==s[3]:
    print("Yes")
elif s[0]==s[2] and s[0]!=s[1] and s[1]==s[3]:
    print("Yes")
elif s[0]==s[3] and s[0]!=s[1] and s[1]==s[2]:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
if (S.count(S[0]) == 2) and (S[1] == S[2] or S[1] == S[3] or S[2] == S[3]):
    print("Yes")
else:
    print("No")

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

Solution (Python):
S = input()
a = S.count(S[0])
b = S.count(S[1])
c = S.count(S[2])
d = S.count(S[3])
if (a==b==c==d==2):
  print("Yes")
else:
  print('No')

Solution (Python):
s=input()
if s[0]==s[1]==s[2]==s[3]:
    print("No")
elif (s[0]==s[1] and s[2]==s[3]) or (s[0]==s[2] and s[1]==s[3]) or (s[0]==s[3] and s[1]==s[2]):
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
if (S[0] == S[1] and S[2] == S[3] and S[0] != 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")

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

Solution (Python):
S = input()

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

Solution (Python):

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

Solution (Python):
s = input().strip()
from collections import defaultdict
d = defaultdict(int)
for c in s:
    d[c] += 1
for k in d:
    if d[k] != 2:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
a = list(input()) 
s= set(a) 
l = list(s) 
if len(a) == 4 and len(s) == 2 and a.count(l[0]) ==2 and a.count(l[1]) ==2: 
    print('Yes') 
else: 
    print('No')

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

Solution (Python):
a=input()
if a[0] is not a[2] or a[0] is not a[3]:
    if a[0] == a[1] and a[2] == a[3]:
        print('Yes')
    elif a[0] == a[3] and a[2] == a[1]:
        print('Yes')    
    elif a[0] == a[2] and a[3] == a[1]:
        print('Yes')
    else:
        print('No')
 
else:
    print('No')

Solution (Python):
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect




from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')

def main():
  s = input()
  count = Counter(s)
  ans = 'Yes'
  for i in count.values():
    if i != 2:
      ans = 'No'
  print(ans)
  
  
  
  
  
if __name__ == '__main__':
  main()

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

Solution (Python):
a=input()
if a[0] is not a[2] or a[0] is not a[3]:
    if a[0] == a[1] and a[2] == a[3]:
        print('Yes')
    elif a[0] == a[3] and a[2] == a[1]:
        print('Yes')    
    elif a[0] == a[2] and a[3] == a[1]:
        print('Yes')
    else:
        print('No')

else:
    print('No')

Solution (Python):
s = list(input())
a = 0
for i in range(len(s)):
  if s.count(s[i]) != 2:
    a += 1
    print('No')
    break
    
if a == 0:
  print('Yes')

Solution (Python):
s=list(input())
n=len(set(s))
if n == 2:
  print("Yes")
else:
  print("No")

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
from collections import Counter
def main():
    c = Counter(list(input()))
    if len(c) != 2:
        print('No')
        exit()
    if c.most_common()[0][1] != 2:
        print('No')
        exit()
    print('Yes')

if __name__ == '__main__':
    main()

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

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