a = gets.chomp
if a.length == 4
    if a[0] == a[1] && a[2] == a[3] && a[1] != a[2]
     puts "Yes"
        elsif a[0] == a[2] && a[1] == a[3] && a[0] != a[1]
     puts "Yes"
        elsif a[0] == a[3] && a[1] == a[2] && a[0] != a[1]
        puts "Yes"
    else
    puts "NO"
    end
end