import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int cnt = 0;

        for(int i = 0;i < 4;i++){
            char ch = s.charAt(i);
            for(int j = i+1;j < 4;j++){
                if(s.charAt(i) == s.charAt(j)){
                    cnt++;
                }
            }
        }
        System.out.println(cnt == 2?"Yes" : "No");
    }
} import java.util.*; util.* java class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int cnt = 0;

        for(int i = 0;i < 4;i++){
            char ch = s.charAt(i);
            for(int j = i+1;j < 4;j++){
                if(s.charAt(i) == s.charAt(j)){
                    cnt++;
                }
            }
        }
        System.out.println(cnt == 2?"Yes" : "No");
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int cnt = 0;

        for(int i = 0;i < 4;i++){
            char ch = s.charAt(i);
            for(int j = i+1;j < 4;j++){
                if(s.charAt(i) == s.charAt(j)){
                    cnt++;
                }
            }
        }
        System.out.println(cnt == 2?"Yes" : "No");
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int cnt = 0;

        for(int i = 0;i < 4;i++){
            char ch = s.charAt(i);
            for(int j = i+1;j < 4;j++){
                if(s.charAt(i) == s.charAt(j)){
                    cnt++;
                }
            }
        }
        System.out.println(cnt == 2?"Yes" : "No");
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int cnt = 0; cnt 0 for(int i = 0;i < 4;i++){
            char ch = s.charAt(i);
            for(int j = i+1;j < 4;j++){
                if(s.charAt(i) == s.charAt(j)){
                    cnt++;
                }
            }
        } int i = 0; int i = 0; i 0 i < 4 i 4 i++ i++ i {
            char ch = s.charAt(i);
            for(int j = i+1;j < 4;j++){
                if(s.charAt(i) == s.charAt(j)){
                    cnt++;
                }
            }
        } {
            char ch = s.charAt(i);
            for(int j = i+1;j < 4;j++){
                if(s.charAt(i) == s.charAt(j)){
                    cnt++;
                }
            }
        } char ch = s.charAt(i); ch s.charAt(i) s.charAt s i for(int j = i+1;j < 4;j++){
                if(s.charAt(i) == s.charAt(j)){
                    cnt++;
                }
            } int j = i+1; int j = i+1; j i+1 i 1 j < 4 j 4 j++ j++ j {
                if(s.charAt(i) == s.charAt(j)){
                    cnt++;
                }
            } {
                if(s.charAt(i) == s.charAt(j)){
                    cnt++;
                }
            } if(s.charAt(i) == s.charAt(j)){
                    cnt++;
                } s.charAt(i) == s.charAt(j) s.charAt(i) s.charAt s i s.charAt(j) s.charAt s j {
                    cnt++;
                } cnt++ cnt System.out.println(cnt == 2?"Yes" : "No") System.out.println System.out System System.out cnt == 2?"Yes" : "No" cnt == 2 cnt 2 "Yes" "No" String[] args args
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int cnt = 0;

        for(int i = 0;i < 4;i++){
            char ch = s.charAt(i);
            for(int j = i+1;j < 4;j++){
                if(s.charAt(i) == s.charAt(j)){
                    cnt++;
                }
            }
        }
        System.out.println(cnt == 2?"Yes" : "No");
    }
}