"use strict"

const main = lines => {

  lines[0] = [...lines[0]]
  
  let k = {}
  for (const val of lines[0]) k[val] = k[val] ? k[val] + 1 : 0
  
  let r = Object.keys(k).length > 2 ? 'No' : 'Yes'
  if (k[lines[0][0]] !== 2) r = 'No'
  
  console.log(r)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').split('\n'))