str = $stdin.gets.chomp

ans = "No"

if str[0] == str[1] and str[2] == str[3] and str[0] != str[2]
  ans = "Yes"
elsif str[0] == str[2] and str[1] == str[3] and str[0] != str[1]
  ans = "Yes"
elsif str[0] == str[3] and str[1] == str[2] and str[0] != str[1]
  ans = "Yes"
end

puts ans