"use strict";
    
const main = arg => {
  	let txtArr = arg.split("");
  	let ans = 'No';
	let NewArr = txtArr.sort();
  	if((NewArr[0] == NewArr[1]) && (NewArr[2] == NewArr[3]) && (NewArr[1] != NewArr[3])){
    	ans = 'Yes';
    }
  	console.log(ans);
  	
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
