#!/usr/bin/env ruby

# MOD = (10 ** 9) + 7
str = gets.chomp

hash = {}
hash[str[0]] = 1
hash[str[1]] = (hash[str[1]] || 0) + 1
hash[str[2]] = (hash[str[2]] || 0) + 1
hash[str[3]] = (hash[str[3]] || 0) + 1

flag = true
hash.keys.each do |key|
  flag = false if hash[key] !=2
end

puts flag ? 'Yes' : 'No'