str = gets.split("")

if str[0] == str[1] && str[1] != str[2] && str[2] == str[3] && str[3] != str[0]
print("Yes")
elsif  str[0] == str[2] && str[1] == str[3] && str[0] != str[1] && str[2] != str[3]
print("Yes")
elsif str[0] == str[3] && str[1] == str[2] && str[0] != str[1]
print("Yes")
else
print("No")
end