#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 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";
}