let S  = readLine()!
let C = Array(S.characters)

var count = [Character: Int]()

for c in C{
  if (count[c] == nil){
    count[c] = 1
  }
  else{
    if let a = count[c]{
    	count[c] = a + 1
    }
  }
}

var ans = "Yes"
for i in count.values {
  if i != 2 {
    ans = "No"
  }
}

if count.count != 2 {
  ans = "No"
}