function Main(input) {
  var tmp = input.split('');
  if ( (tmp[0] === tmp[3]) && (tmp[1] === tmp[2]) && (tmp[0] !== tmp[1])) {
    console.log('Yes');
    return;
  } else if ( (tmp[1] === tmp[3]) &&(tmp[0] === tmp[2]) && (tmp[1] !== tmp[2])) {
    console.log('Yes');
    return;
  } else if ((tmp[2] === tmp[3]) &&(tmp[0] === tmp[1]) && (tmp[0] !== tmp[2])){
    console.log('Yes');
    return;
  }
  console.log('No');
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));