S = gets.strip


s=[]
S.chars do |ss|
    s<<ss
end

su=s.uniq
if su.length!=2
    puts "No"
    exit
end
a=S[0]
c=0
s.each do |ss|
    if a==ss
        c+=1
    end
end
if c==2
    puts "Yes"
else
    puts "No"
end
