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