s = gets.chomp.split("")

if s[1] == s[0]
    if s[2] == s[3] && s[0] != s[2]
        puts "Yes"
    else
        puts "No"
    end
elsif s[2] == s[0]
    if s[1] == s[3] && s[0] != s[1]
        puts "Yes"
    else
        puts "No"
    end
elsif s[3] == s[0]
    if s[2] == s[1] && s[0] != s[1]
        puts "Yes"
    else
        puts "No"
    end
else
    puts "No"
end


