s = gets.split("")

if (((s[0]==s[1]) and (s[2]==s[3]) and (s[0]!=s[2])) or ((s[0]==s[2]) and (s[1]==s[3]) and (s[0]!=s[1])) or ((s[0]==s[3]) and (s[1]==s[2]) and (s[0]!=s[1])))
  puts 'Yes'
else
  puts 'No'
end
