a = gets.chomp.split('').map(&:to_s)
# p a

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