#include<iostream>
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include <cstdlib>
#include <climits>
#include <iomanip>
#include<iostream>
#include <sstream>  // for string streams
#include <string>  // for string
#include <stack> 
#include <cmath>
 
#pragma comment(linker, "/STACK:2000000")
#pragma comment(linker, "/HEAP:2000000")
 
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define f(n) for(ll i=0;i<n;i++)
#define fn(a,n) for(ll a=0; a<n; a++)
#define flr(a,l,r) for(ll a=l; a<=r;a++)
#define mp make_pair
#define sorta(a) sort(a.begin(), a.end());
#define sortd(a) sort(a.begin(), a.end(), greater<ll>());
#define sortdp(a) sort(a.begin(), a.end(), greater<pair<ll, ll>>());
#define vec std::vector<ll>
#define vp std::vector<pair<ll, ll>>
#define all(a) a.begin(), a.end()
#define inf (long long)1e18
#define infi (int)1e9
#define endl '\n'
#define ff(a, b) for (ll i = 0; i < a; i++) for (ll j = 0; j < b; j++)
#define pp1(a) cout << a << endl;
#define pp2(a, b) cout << a << " " << b << endl;
#define pp3(a, b, c) cout << a << " " << b << " " << c << endl;
#define pp4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl;
#define vvl vector<vector<ll>>
#define vvc std::vector<std::vector<char>>
#define vvi std::vector<std::vector<int>>
#define blb(a, b) lower_bound(all(a), b) - a.begin();
#define bub(a, b) upper_bound(all(a), b) - a.begin();
#define graph(n) vvl g(n + 1, vector<ll>(0));
#define in(a, n) vec a(n); f (n) cin >> a[i];
 
//#define p(n) cout<<n<<"\n";
#define MOD 1000000007
 
 
using namespace std;
 
 
void print_width(ll x) {
 
    std::cout << std::fixed;
    std::cout << std::setprecision(x);
}
 
ll power(ll x, ll y, ll p = MOD)
{ 
    ll res = 1;      // Initialize result 
 
    x = x % p;  // Update x if it is more than or  
                // equal to p 
 
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % p; 
 
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p;   
    } 
    return res; 
} 
 
void printArr(ll a[], ll n) {
    f(n)
        cout << a[i] << " ";
    cout << endl;
}
 
void printVector(std::vector<ll> v) {
    f(v.size())
        cout << v[i] << " ";
    cout << endl;
}
 
void printVectorPair(std::vector<pair<ll, ll>> v) {
    f(v.size())
        pp2(v[i].first, v[i].second);
    cout << endl;
}
 
ll Min(ll a, ll b, ll c) {
    if (a < b and a < c)
        return a;
    if (b < c)
        return b;
    return c;
}
 
void initialize(ll arr[], ll n) {
    for (ll i = 0; i <= n; i++)
        arr[i] = i;
}
 
ll root(ll arr[], ll i) {
 
    while (arr[i] != i) {
        arr[ i ] = arr[ arr[ i ] ] ; 
        i = arr[i];
    }
    return i;
 
}
 
void Union(ll arr[], ll a, ll b) {
    ll root_a = root(arr, a);
    ll root_b = root(arr, b);
 
    arr[root_a] = root_b;
}
 
 
ll gcd (ll a, ll b) {
    if (b == 0)
        return a;
    else return gcd(b, a % b);
}
 
ll power_wm(ll x, ll y)
{ 
    ll res = 1;      // Initialize result 
 
 
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x); 
 
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x);   
    } 
    return res; 
} 
 
long double dpower(long double x, ll y) { 
    long double res = 1;      // Initialize result 
 
 
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x); 
 
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x);   
    } 
    return res; 
}
 
std::vector<ll> vsum(std::vector<ll> a) {
 
    std::vector<ll> s(a.size());
    s[0] = a[0];
    flr (i, 1, a.size() - 1) {
        s[i] = s[i - 1] + a[i];
    }
    return s;
}
 
bool comp( pair<ll, ll> a, pair<ll, ll> b) {
    ll x = a.second * b.first;
    ll y = a.first * b.second;
 
    if (x <= y)
        return false;
    else
        return true;
}
 
bool is_cap(char a) {
 
    if (a <= 'Z' and a >= 'A')
        return true;
    else
        return false;
}
 
bool is_small(char a) {
 
    if (a <= 'z' and a >= 'a')
        return true;
    else
        return false;
}
 
string findSum(string str1, string str2) 
{ 
    string str = ""; 
    if (str1.size() > str2.size())  {
        swap(str1, str2); 
    }
 
    int n1 = str1.size(), n2 = str2.size(); 
  
    reverse(all(str1)); 
    reverse(all(str2)); 
  
    int carry;
    carry = 0;
    for (int i = 0; i<n1; i++) { 
        int sum;
        sum = ((str1[i]-'0')+(str2[i]-'0')+carry); 
        str.pb(sum%10 + '0'); 
  
        carry = sum / 10; 
    } 
  
    for (int i=n1; i<n2; i++)  { 
        int sum;
        sum = ((str2[i]-'0')+carry); 
        str.pb(sum%10 + '0'); 
        carry = sum/10; 
    } 
  
    if (carry) 
        str.pb(carry+'0'); 
  
    reverse(all(str)); 
  
    return str; 
} 
 
bool mcomp(ll a, ll b, ll c, ll d) {
 
    if (a == b and b == c and c == d)
        return true;
    else
        return false;
 
}
 
// vector<vector<pair<ll, ll>>> adj;
// void dijikstra(int s, vector<ll> & d, vector<ll> & p) {
 
//     ll n = adj.size();
//     d.assign(n, inf);
//     p.assign(n, -1);
 
//     d[s] = 0;
//     set<pair<ll, ll>> q;
//     q.insert({0, s});
 
//     while (!q.empty()) {
 
//         ll v = q.begin() -> second;
//         q.erase(q.begin());
 
//         for (auto edge: adj[v]) {
 
//             ll to = edge.first;
//             ll len = edge.second;
 
//             if (d[v] + len < d[to]) {
//                 q.erase({d[to], to});
//                 d[to] = d[v] + len;
//                 p[to] = v;
//                 q.insert({d[to], to});
//             }
 
//         }
 
//     }
 
// }
 
vvl g(200001, vector<ll>(0));
ll dfs(ll x, vec &vis, vec &dfs_seq, vec &children) {
 
    dfs_seq.pb(x);
    for (ll i = 0; i < g[x].size(); i++) {
 
        ll y = g[x][i];
        if (vis[y] == 0) {
            vis[y] = 1;
            dfs(y, vis, dfs_seq, children);
            children[x] += 1 + children[y];
        }
    }
    return 0;
}
 
ll c2(ll n) {
    return (n * (n - 1)) / 2;
}

void time() {
    #ifndef ONLINE_JUDGE
    cout << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
    #endif
}

int main() {
 

 
    //FastIO
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
 
    // start your code here
    // print_width(15);

    
    string s;
    cin >> s;

    sorta(s);

    if (s[0] == s[1] and s[2] == s[3] and s[1] != s[2]) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }


    // time();
    return 0;
}

Measured memory_bytes: 4992