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: Accepted)

using System;
using System.Collections.Generic;
using System.Text;

namespace codeTester.contest190629
{
    class ProblemA
    {
        static string value = "";
        static string answer = "";

        public static void Main(string[] args)
        {
            Input();
            Logic();
            Output();
        }

        static void Input()
        {
            value = Console.ReadLine();
        }

        static void Logic()
        {
            // １文字目と２文字目が同じ場合
            if (value[0] == value[1])
            {
                if (value[2] != value[0] && value[2] == value[3])
                {
                    answer = "Yes";
                }
                else
                {
                    answer = "No";
                }
                return;
            }

            // １文字目と２文字目が異なる場合
            int word1Count = 1;
            int word2Count = 1;
            if (value[2] == value[0])
            {
                word1Count++;
            }
            if (value[2] == value[1])
            {
                word2Count++;
            }
            if (value[3] == value[0])
            {
                word1Count++;
            }
            if (value[3] == value[1])
            {
                word2Count++;
            }
            if (word1Count == 2 && word2Count == 2)
            {
                answer = "Yes";
                return;
            }
            answer = "No";
        }

        static void Output()
        {
            Console.WriteLine(answer);
        }
    }
}