arr = gets.chomp.split('')

unless arr.uniq.length == 2
  print 'No'
  exit
end

tmp_a = []
arr.uniq.each do |s|
  tmp_a.push(arr.select { |i| i == s }.count)
end

if tmp_a.select { |i| i == 2 }.length == 2
  print 'Yes'
else
  print 'No'
end
