function Main(input) {
	const s = input
	const t1 = {}

	for (var i = 0; i < s.length; i++) {
		if (!(s[i] in t1)) t1[s[i]] = 0
		t1[s[i]]++
	}

	const keys = Object.keys(t1)

	if (keys.length === 2 && keys.every(key => t1[key] === 2)) {
		console.log('Yes')
	} else {
		console.log('No')
	}
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))
