S = gets.chomp

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