Problem:
Score : 100 points

Problem Statement

You are given a 4-character string S consisting of uppercase English letters.
Determine if S consists of exactly two kinds of characters which both appear twice in S.

Constraints

The length of S is 4.

S consists of uppercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

If S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.

Sample Input 1

ASSA

Sample Output 1

Yes

S consists of A and S which both appear twice in S.

Sample Input 2

STOP

Sample Output 2

No

Sample Input 3

FFEE

Sample Output 3

Yes

Sample Input 4

FREE

Sample Output 4

No

Solution in JavaScript (node.js v5.12) (judge verdict: Accepted)

// inputに入力データ全体が入る
function Main(input) {
  chars = input.split("");
  	
  	//入力が全て同じ文字だったらNoを返す
	if(chars[0] == chars[1] && chars[0] == chars[2] && chars[0] == chars[3]){
       console.log("No");
	}else{
      //chars[i]は後から変わるので、先に定数として定義
      var letter = chars[0];
      
      //最初のアルファベットをまず消す
      chars.splice(0,1);
      var replaced = input.replace(letter, '');
      var search = replaced.search(letter);

      //最初のアルファベットと同じやつがないか探して、あったら消す
      chars.splice(search,1);
      replaced = replaced.replace(letter, '');
      search = replaced.search(letter);

      //残りの２文字が一緒だったらYes、一緒じゃない場合はNo
      if(chars[0] == chars [1]) 
        console.log("Yes");
      else console.log("No");
    }
}
  
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));