import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        String S = scan.next();

        char[] array = S.toCharArray();

        if(array[0] == array[1] && array[2] == array[3] && array[1] != array[2]){

            System.out.println("Yes");
            return;

        }else if(array[0] == array[2] && array[1] == array[3] && array[1] != array[2]){

            System.out.println("Yes");
            return;

        }else if (array[0] == array[3] && array[1] == array[2] && array[0] != array[1]){

            System.out.println("Yes");
            return;
        }
        
        System.out.println("No");
        return;

    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        String S = scan.next();

        char[] array = S.toCharArray();

        if(array[0] == array[1] && array[2] == array[3] && array[1] != array[2]){

            System.out.println("Yes");
            return;

        }else if(array[0] == array[2] && array[1] == array[3] && array[1] != array[2]){

            System.out.println("Yes");
            return;

        }else if (array[0] == array[3] && array[1] == array[2] && array[0] != array[1]){

            System.out.println("Yes");
            return;
        }
        
        System.out.println("No");
        return;

    }
} Main public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        String S = scan.next();

        char[] array = S.toCharArray();

        if(array[0] == array[1] && array[2] == array[3] && array[1] != array[2]){

            System.out.println("Yes");
            return;

        }else if(array[0] == array[2] && array[1] == array[3] && array[1] != array[2]){

            System.out.println("Yes");
            return;

        }else if (array[0] == array[3] && array[1] == array[2] && array[0] != array[1]){

            System.out.println("Yes");
            return;
        }
        
        System.out.println("No");
        return;

    } main {

        Scanner scan = new Scanner(System.in);
        String S = scan.next();

        char[] array = S.toCharArray();

        if(array[0] == array[1] && array[2] == array[3] && array[1] != array[2]){

            System.out.println("Yes");
            return;

        }else if(array[0] == array[2] && array[1] == array[3] && array[1] != array[2]){

            System.out.println("Yes");
            return;

        }else if (array[0] == array[3] && array[1] == array[2] && array[0] != array[1]){

            System.out.println("Yes");
            return;
        }
        
        System.out.println("No");
        return;

    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String S = scan.next(); S scan.next() scan.next scan char[] array = S.toCharArray(); array S.toCharArray() S.toCharArray S if(array[0] == array[1] && array[2] == array[3] && array[1] != array[2]){

            System.out.println("Yes");
            return;

        }else if(array[0] == array[2] && array[1] == array[3] && array[1] != array[2]){

            System.out.println("Yes");
            return;

        }else if (array[0] == array[3] && array[1] == array[2] && array[0] != array[1]){

            System.out.println("Yes");
            return;
        } array[0] == array[1] && array[2] == array[3] && array[1] != array[2] array[0] == array[1] && array[2] == array[3] && array[1] != array[2] array[0] == array[1] array[0] array 0 array[1] array 1 array[2] == array[3] array[2] array 2 array[3] array 3 array[1] != array[2] array[1] array 1 array[2] array 2 {

            System.out.println("Yes");
            return;

        } System.out.println("Yes") System.out.println System.out System System.out "Yes" return; if(array[0] == array[2] && array[1] == array[3] && array[1] != array[2]){

            System.out.println("Yes");
            return;

        }else if (array[0] == array[3] && array[1] == array[2] && array[0] != array[1]){

            System.out.println("Yes");
            return;
        } array[0] == array[2] && array[1] == array[3] && array[1] != array[2] array[0] == array[2] && array[1] == array[3] && array[1] != array[2] array[0] == array[2] array[0] array 0 array[2] array 2 array[1] == array[3] array[1] array 1 array[3] array 3 array[1] != array[2] array[1] array 1 array[2] array 2 {

            System.out.println("Yes");
            return;

        } System.out.println("Yes") System.out.println System.out System System.out "Yes" return; if (array[0] == array[3] && array[1] == array[2] && array[0] != array[1]){

            System.out.println("Yes");
            return;
        } array[0] == array[3] && array[1] == array[2] && array[0] != array[1] array[0] == array[3] && array[1] == array[2] && array[0] != array[1] array[0] == array[3] array[0] array 0 array[3] array 3 array[1] == array[2] array[1] array 1 array[2] array 2 array[0] != array[1] array[0] array 0 array[1] array 1 {

            System.out.println("Yes");
            return;
        } System.out.println("Yes") System.out.println System.out System System.out "Yes" return; System.out.println("No") System.out.println System.out System System.out "No" return; String[] args args public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        String S = scan.next();

        char[] array = S.toCharArray();

        if(array[0] == array[1] && array[2] == array[3] && array[1] != array[2]){

            System.out.println("Yes");
            return;

        }else if(array[0] == array[2] && array[1] == array[3] && array[1] != array[2]){

            System.out.println("Yes");
            return;

        }else if (array[0] == array[3] && array[1] == array[2] && array[0] != array[1]){

            System.out.println("Yes");
            return;
        }
        
        System.out.println("No");
        return;

    }
} public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        String S = scan.next();

        char[] array = S.toCharArray();

        if(array[0] == array[1] && array[2] == array[3] && array[1] != array[2]){

            System.out.println("Yes");
            return;

        }else if(array[0] == array[2] && array[1] == array[3] && array[1] != array[2]){

            System.out.println("Yes");
            return;

        }else if (array[0] == array[3] && array[1] == array[2] && array[0] != array[1]){

            System.out.println("Yes");
            return;
        }
        
        System.out.println("No");
        return;

    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        String S = scan.next();

        char[] array = S.toCharArray();

        if(array[0] == array[1] && array[2] == array[3] && array[1] != array[2]){

            System.out.println("Yes");
            return;

        }else if(array[0] == array[2] && array[1] == array[3] && array[1] != array[2]){

            System.out.println("Yes");
            return;

        }else if (array[0] == array[3] && array[1] == array[2] && array[0] != array[1]){

            System.out.println("Yes");
            return;
        }
        
        System.out.println("No");
        return;

    }
}