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

#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << (#x) << " is " << (x) << endl
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define open freopen(input.txt,"r",stdin); freopen(output.txt,"w",stdout);
#define precise(t) cout << fixed << setprecision(t)
#define forr(i,n) for(int i(0);i<n;++i)
#define repup(i,a,b) for(int i(a); i <=b; ++i)
#define repdown(i,a,b) for(int i(a);i>=b;i--)
#define testcase(t) int t; cin >> t; wl(t)
#define input(n) int n; cin >> n;
#define sz(a) int((a).size())
#define pb push_back
#define pf push_front
#define mp make_pair
#define ff first
#define ss second
#define bb begin()
#define ee end()
#define all(c) c.bb, c.ee
#define tr(container, it) for (auto it = container.begin(); it != container.end(); it++)
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) * (b)) / gcd((a), (b))
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef map<char,int> mci;
typedef pair<int, int> pii;
typedef map<int,pii> ipii;

const int inf = INT_MAX; 
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846264338;


int main(){
	char arr[4];
	forr(i,4) {cin >> arr[i];}
	sort(arr,arr+4);
	if(arr[0]==arr[1] && arr[2]==arr[3] && arr[1]!=arr[2]){
		cout << "Yes";
	}
	else{
		cout << "No";
	}

}