s = gets.chomp
hash = {}
for i in 0...4 do
  if hash.include?(s[i])
    hash[s[i]] += 1
  else
    hash[s[i]] = 1
  end
end
flag = true
count = 0
hash.each { |k, v|
  flag = false if v != 2
  count += 1
}
puts (count == 2 && flag) ? "Yes" : "No"
