#include <bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  sort(a.begin(), a.end());
  if (a[0] != a[3] && a[0] == a[1] && a[2] == a[3])  {
    cout << "Yes";
  } else {
    cout << "No";
  }
}