const fs = require('fs')

const input = fs.readFileSync('/dev/stdin', 'utf8')

const S = input.trim()

const counter = {}

for (let i=0; i<4; i++) {
  const c = S.substr(i, 1)
  if (c in counter) {
    counter[c] = counter[c] + 1
  } else {
    counter[c] = 1    
  }
}

if (counter[S.substr(0, 1)] === 2) {
  console.log('Yes')
} else {
  console.log('No')
}
