from collections import defaultdict



def solve():

    S = list(eval(input()))

    d = defaultdict(int)

    for key in S:

        d[key] = d[key] + 1

    ans = 'Yes'

    for v in list(d.values()):

        if v != 2:

            ans = 'No'

    return ans



print((solve()))
def solve():

    S = list(eval(input()))

    S.sort()

    ans = 'No'

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

        ans = 'Yes'

    return ans



print((solve()))
from collections import defaultdict


def solve():
    S = list(eval(input()))
    d = defaultdict(int)
    for key in S:
        d[key] = d[key] + 1
    ans = "Yes"
    for v in list(d.values()):
        if v != 2:
            ans = "No"
    return ans


print((solve()))

def solve():
    S = list(eval(input()))
    S.sort()
    ans = "No"
    if S[0] == S[1] and S[1] != S[2] and S[2] == S[3]:
        ans = "Yes"
    return ans


print((solve()))

-from collections import defaultdict - - -    d = defaultdict(int) -    for key in S: -        d[key] = d[key] + 1 -    ans = "Yes" -    for v in list(d.values()): -        if v != 2: -            ans = "No" +    S.sort() +    ans = "No" +    if S[0] == S[1] and S[1] != S[2] and S[2] == S[3]: +        ans = "Yes"