h = Hash.new(0)
s = gets.chomp
4.times do |i|
  h[s[i]] += 1
end
if h.keys.length != 2
    puts "No"
    exit
end
h.values.each do |e|
    if e != 2
        puts "No"
        exit
    end
end
puts "Yes"