n = gets.chop

counts = {} 

for i in 0..3
  if counts[n[i]].nil?
    counts[n[i]] = 1
    next
  end
  counts[n[i]]+=1
end

for i in 0..3
  if counts[n[i]] != 2
    puts "No"
    exit
  end
end

puts "Yes"

