"use strict"
function main(arg) {
    arg = arg.trim().split("\n")[0].split('').sort()
    if (arg[0] == arg[1] && arg[2] == arg[3] && arg[0] != arg[3]) {
        console.log('Yes')
    } else {
        console.log('No')
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));