var str = [];
var count = 0;

function Main(input) {

	input = input.split("");
	
	for(var i = 0;i < 4;i++){
	    str[i] = input[i];
	}
	
	if(str[0]===str[1]){
	    if(str[2]===str[3]&&str[0]!==str[2]&&str[0]!==str[3]&&str[1]!==str[2]&&str[1]!==str[3]){
	        console.log("Yes");
	    }else{
	        console.log("No");
	    }
	}else if(str[0]===str[2]){
	    if(str[1]===str[3]&&str[0]!==str[1]&&str[0]!==str[3]&&str[2]!==str[1]&&str[2]!==str[3]){
	        console.log("Yes");
	    }else{
	        console.log("No");
	    }
	}else if(str[0]===str[3]){
	    if(str[2]===str[1]&&str[0]!==str[2]&&str[0]!==str[1]&&str[3]!==str[2]&&str[1]!==str[3]){
	        console.log("Yes");
	    }else{
	        console.log("No");
	    }
	}else{
        console.log("No");
    }
}

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