'use strict';

function main(input){
    const S = input[0];
    let f=true;
    for(let i=0;i<4;i++){
        let count=S.split('').filter(x => x===S[i]).length
        if(count !== 2){
            f=false;
            break;
        }
    }
    if(f) console.log("Yes");
    else console.log("No");
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').split('\n'))