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# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

class Program {
    static void Main (string[] args) {
          

        string str = Console.ReadLine ();
        
        char a = str[0];
        char b = str[1];
        char c = str[2];
        char d = str[3];

        int flg = 0;
        int flg2 = 0;

        
        for(int i=1;i<4;i++){
            if(str[0].Equals(str[i])){
                flg++;
            }
        }
        if(flg == 1)flg2 ++;
        flg = 0;
        for(int i=0;i<4;i++)
        {
            if(i != 1){
            if(str[1].Equals(str[i])){
                flg++;
            }
            }
        }
        if(flg == 1)flg2 ++; 
        flg = 0;
        for(int i=0;i<4;i++)
        {
            if(i != 2){
            if(str[2].Equals(str[i])){
                flg++;
            }
            }
        }
        if(flg == 2)flg2 ++; 
                for(int i=0;i<4;i++)
        {
            if(i != 3){
            if(str[3].Equals(str[i])){
                flg++;
            }
            }
        }
        if(flg == 1)flg2 ++; 

        string ans = "No";
        if(flg2 == 2) ans = "Yes"; 

       
        Console.WriteLine(ans);
    }
}