"use strict"

const main = (input) => {
    const S = input.split("");
    let sum1 = 0;
    let sum2 = 0;

    const a = S[0];
    for (let i = 0; i < S.length; i++) {
        if (a == S[i]) {
            sum1 += 1;
        } else {
            sum2 += 1;
        }
    }

    if (sum1 == 2 && sum2 == 2) {
        console.log("Yes");
    } else {
        console.log("No");
    }
};

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