#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	char s[4];
	for (int i = 0; i < 4; i++)
		cin >> s[i];
	char k = 'g';
	int sum = 0;
	for (int i = 0; i < 4; i++)
	{
		for(int j=0;j<i;j++)
			if (s[j] == s[i])
			{
				sum++;
				break;
			}
	}
	if (sum == 2) cout << "Yes" << endl;
	else cout << "No" << endl;
	/*char a,b,c,d;
	cin >> a >> b >> c >> d;
	if (a == b && c == d && a != c) cout << "Yes";
	else if (a == c && b == d && a != b) cout << "Yes";
	else if (a == d && c == b && a != c) cout << "Yes";
	else if (a == b && c == d && a != c) cout << "Yes";
	else cout << "No";*/
}