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