function Main(input) {
  lines = input.split("\n")
  S = lines[0].split("")
  a = {}
  for (var i = 0; i < S.length ; i++) {
    if (!a[S[i]]) {
      a[S[i]] = 0
    }      
    a[S[i]] += 1
  }
  cnt = 0
  bool = true
  for (var k in a) {
    if (a[k] != 2) {
        bool = false
    }
    cnt++
  }
  if (cnt != 2) {
      bool = false
  }
  ans = bool ? 'Yes' : 'No'
  console.log(ans)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
