
function Main(input) {
    var S = input.toString();
    var s1 = S.charAt(0);
    var s2 = S.charAt(1);
    var s3 = S.charAt(2);
    var s4 = S.charAt(3);

    if (s1 === s2) {
        if (s3 === s4) {
            console.log('Yes');
        } else {
            console.log('No');
        }
    } else if (s1 === s3) {
        if (s2 === s4) {
            console.log('Yes');
        } else {
            console.log('No');
        }
    } else if (s1 === s4) {
        if (s2 === s3) {
            console.log('Yes');
        } else {
            console.log('No');
        }
    } else {
        console.log('No');
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));