#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);


    ll ans=0;
    ll anss =0;
    ll count=0;
    ll i,j;
  
    ll K;
    vector<ll> a;

    ll Q,N;
    string S;
    cin>>S;
    ll flag=0;
    ll t1=0;
    ll t2=0;
    
        if(S[0]==S[1]){
            if(S[2]==S[3]){
            cout<< "Yes" << endl;
            return 0;
            }
        }
    if(S[0]==S[2]){
            if(S[1]==S[3]){
            cout<< "Yes" << endl;
            return 0;
            }
        }if(S[0]==S[3]){
            if(S[2]==S[1]){
            cout<< "Yes" << endl;
            return 0;
            }
        }
       


        cout<< "No" << endl;
return 0;
 
}