s = gets.chomp

if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]
  puts "Yes"
elsif s[0] == s[2] and s[1] == s[3] and s[0] != s[1]
  puts "Yes"
elsif s[0] == s[3] and s[1] == s[2] and s[0] != s[1]
  puts "Yes"
else
  puts "No"
end