str = gets
sorted_str =  str.chars.sort.join

condition = (sorted_str[0] == sorted_str[1]) && (sorted_str[2] == sorted_str[3]) && (sorted_str[0] != sorted_str[2])
condition ? result = "Yes" : result = "No"

print result