function main(input) {
  const inputList = input.split('');
  const A = inputList[0];
  const B = inputList[1];
  const C = inputList[2];
  const D = inputList[3];
  var result = 'No';
  if (A === B && C === D && A !== C ||
     A === C && B === D && A !== B ||
     A === D && B === C && A !== B) {
    result = 'Yes';
  }
  console.log(result);
};

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