"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0].split("");
    const set = new Set(S);
    const unique = [...set];
    
    if(set.size !== 2) {
        console.log("No");
        return;
    }
    
    for(let i in unique) {
        if(S.filter(n=>n===unique[i]).length !== 2) {
            console.log("No");
            return;
        }
    }
    
    console.log("Yes");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));