#include <bits/stdc++.h>

using namespace std;

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