const main = (inputs) => {
  var S = inputs[0].split("");
  var tmp = {};
  S.forEach(v=>{
    tmp[v] = (tmp[v]||0)+1
  });
  var ans = true;
  if(Object.keys(tmp).length!=2) ans = false;
  else if(Object.keys(tmp).filter(v=>tmp[v]!=2).length != 0){
    ans = false;
  }
  
  console.log(ans?"Yes":"No");
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));
