input = gets.chomp.split("")
unique = input.uniq
answer = true
answer = false if unique.size != 2
unique.each do |char|
    answer = false if input.select{|c| c == char}.size != 2
end
puts answer ? "Yes" : "No"