S = gets.chomp

c = Hash.new{|h, k| h[k] = 0}
(0...S.size).each{|i| c[S[i]] += 1}

ans = 'Yes'
if c.size == 2 then
  if c.any?{|k, v| v != 2} then
    ans = 'No'
  end
else
  ans = 'No'
end

puts ans
