import java.util.*;
import java.math.*;
public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    //static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] str = s.toCharArray();
        if(str[0]==str[1]){
            if(str[2]==str[3]&&str[1]!=str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else if(str[0]==str[2]){
            if(str[1]==str[3]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else if(str[0]==str[3]){
            if(str[1]==str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        }
    }       
}



 import java.util.*; util.* java import java.math.*; math.* java public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    //static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] str = s.toCharArray();
        if(str[0]==str[1]){
            if(str[2]==str[3]&&str[1]!=str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else if(str[0]==str[2]){
            if(str[1]==str[3]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else if(str[0]==str[3]){
            if(str[1]==str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        }
    }       
} Main static final int MOD = 1_000_000_007; // 10^9+7 MOD 1_000_000_007 //static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9 INF 1_000_000_000 static final int MAX = 10_000_000; MAX 10_000_000 public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] str = s.toCharArray();
        if(str[0]==str[1]){
            if(str[2]==str[3]&&str[1]!=str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else if(str[0]==str[2]){
            if(str[1]==str[3]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else if(str[0]==str[3]){
            if(str[1]==str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        }
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] str = s.toCharArray();
        if(str[0]==str[1]){
            if(str[2]==str[3]&&str[1]!=str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else if(str[0]==str[2]){
            if(str[1]==str[3]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else if(str[0]==str[3]){
            if(str[1]==str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc char[] str = s.toCharArray(); str s.toCharArray() s.toCharArray s if(str[0]==str[1]){
            if(str[2]==str[3]&&str[1]!=str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else if(str[0]==str[2]){
            if(str[1]==str[3]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else if(str[0]==str[3]){
            if(str[1]==str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        } str[0]==str[1] str[0] str 0 str[1] str 1 {
            if(str[2]==str[3]&&str[1]!=str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        } if(str[2]==str[3]&&str[1]!=str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            } str[2]==str[3]&&str[1]!=str[2] str[2]==str[3] str[2] str 2 str[3] str 3 str[1]!=str[2] str[1] str 1 str[2] str 2 {
                System.out.println("Yes");
            } System.out.println("Yes") System.out.println System.out System System.out "Yes" {
                System.out.println("No");
            } System.out.println("No") System.out.println System.out System System.out "No" if(str[0]==str[2]){
            if(str[1]==str[3]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else if(str[0]==str[3]){
            if(str[1]==str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        } str[0]==str[2] str[0] str 0 str[2] str 2 {
            if(str[1]==str[3]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        } if(str[1]==str[3]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            } str[1]==str[3] str[1] str 1 str[3] str 3 {
                System.out.println("Yes");
            } System.out.println("Yes") System.out.println System.out System System.out "Yes" {
                System.out.println("No");
            } System.out.println("No") System.out.println System.out System System.out "No" if(str[0]==str[3]){
            if(str[1]==str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        } str[0]==str[3] str[0] str 0 str[3] str 3 {
            if(str[1]==str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        } if(str[1]==str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            } str[1]==str[2] str[1] str 1 str[2] str 2 {
                System.out.println("Yes");
            } System.out.println("Yes") System.out.println System.out System System.out "Yes" {
                System.out.println("No");
            } System.out.println("No") System.out.println System.out System System.out "No" {
            System.out.println("No");
        } System.out.println("No") System.out.println System.out System System.out "No" String args[] args public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    //static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] str = s.toCharArray();
        if(str[0]==str[1]){
            if(str[2]==str[3]&&str[1]!=str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else if(str[0]==str[2]){
            if(str[1]==str[3]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else if(str[0]==str[3]){
            if(str[1]==str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        }
    }       
} public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    //static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] str = s.toCharArray();
        if(str[0]==str[1]){
            if(str[2]==str[3]&&str[1]!=str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else if(str[0]==str[2]){
            if(str[1]==str[3]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else if(str[0]==str[3]){
            if(str[1]==str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        }
    }       
} Main
import java.util.*;
import java.math.*;
public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    //static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] str = s.toCharArray();
        if(str[0]==str[1]){
            if(str[2]==str[3]&&str[1]!=str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else if(str[0]==str[2]){
            if(str[1]==str[3]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else if(str[0]==str[3]){
            if(str[1]==str[2]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        }
    }       
}




