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 C (GCC 5.4.1) (judge verdict: Accepted)

#include<stdio.h>

int main(void){
  char array[4] ;
  char x,y;
  int count_x = 1, count_y = 1;

  scanf("%s",array);
  x = array[0]; // x:1文字目

  if(x != array[1]){ // 1文字目と2文字目が違う
    y = array[1];
    for(int i=0 ; i<2 ; i++){
    if(x == array[i+2])
      count_x++;
    else if(y == array[i+2])
      count_y++;
    }
  }
  else{              // 1文字目と2文字目が同じ 
    count_x++;
    y = array[2];
    if(y == array[3]){
      count_y++;
      if(x == y)   //全て同じ文字のとき
	count_x--; //後の条件から外す
    }
  }


  if(count_x == 2 && count_y == 2)
    printf("Yes\n");
  else
    printf("No\n");


  return 0;
}