a = gets.chomp
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
