s = gets.chomp.chars
if s.uniq.size != 2
  puts "No"
else
  if (s[0] == s[1] && s[2] == s[3]) || (s[0] == s[2] && s[1] == s[3] || s[0] == s[3] && s[1] == s[2])
    puts "Yes"
  else
    puts "No"
  end
end