S = gets.chomp

c = Hash.new(0)

S.chars.each do |s|
  c[s] += 1
end

if c.size == 2
  c.each do |_k, count|
    unless count == 2
      puts 'No'
      exit
    end
  end
  puts 'Yes'
else
  puts 'No'
end
