s = gets.chomp
if s[0] == s[1]
  if s[2] == s[3] && s[0] != s[2]
    puts "Yes"
  else
    puts "No"
  end
elsif s[0] == s[2]
  if s[1] == s[3] && s[0] != s[1]
    puts "Yes"
  else
    puts "No"
  end
elsif s[0] == s[3]
  if s[1] == s[2] && s[0] != s[1]
    puts "Yes"
  else
    puts "No"
  end
else
  puts "No"
end