str = gets.chomp.split('')
uniq = str.uniq

if uniq.length != 2
    puts 'No'
    exit
end

flag = true
uniq.each {|chr|
    flag = false if str.select{|c| c == chr}.length != 2
}

if flag
    puts 'Yes'
else
    puts 'No'
end
