function main(input) {
  // 入力値（文字列）を改行で区切る
  const inputList = input.split('');
  const list = [];
  inputList.forEach(il => {
    if (!list.some(l => l === il)) {
      list.push(il);
    }
  });
  var result = 'No';
  if (list.length === 2) {
    if (inputList.filter(inp => inp === list[0]).length === 2 &&
       inputList.filter(inp => inp === list[1]).length === 2) {
      result = 'Yes';
    }
  }
  console.log(result);
};

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