# A, B = gets.split(" ").map(&:to_i)
S = gets.chomp.split(//)
# N = gets.to_i

h = {}
S.each do |s|
  h[s] ||= 0
  h[s] += 1
end

# p h
ok = h.size == 2 && h.all?{|k,v| v == 2}
puts ok ? 'Yes' : 'No'
