function main(input) {
    var cnt = {};
    if (input.length !== 4){
        console.log("No");
        return;
    }
    for(var i = 0; i < input.length; i++){
        if (cnt.hasOwnProperty(input[i])){
            cnt[input[i]] = cnt[input[i]] + 1;
        }else{
            cnt[input[i]] = 1;
        }
    }
    if(Object.keys(cnt).length === 2 && cnt[input[0]] === 2){
        console.log("Yes");
    }else{
        console.log("No");
    }
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));