import java.util.Scanner;
import java.util.Arrays;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.next();

        int[] A = new int[4];
        for (int i = 0; i < 4; i++) {
            A[i] = str.charAt(i);
        }
        Arrays.sort(A);

        if (A[0] == A[1] && A[2] == A[3] && A[0] != A[3]) {
            System.out.println("Yes");
        } else { 
            System.out.println("No");
        }
    }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.next();

        int[] A = new int[4];
        for (int i = 0; i < 4; i++) {
            A[i] = str.charAt(i);
        }
        Arrays.sort(A);

        if (A[0] == A[1] && A[2] == A[3] && A[0] != A[3]) {
            System.out.println("Yes");
        } else { 
            System.out.println("No");
        }
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.next();

        int[] A = new int[4];
        for (int i = 0; i < 4; i++) {
            A[i] = str.charAt(i);
        }
        Arrays.sort(A);

        if (A[0] == A[1] && A[2] == A[3] && A[0] != A[3]) {
            System.out.println("Yes");
        } else { 
            System.out.println("No");
        }
    } main {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();

        int[] A = new int[4];
        for (int i = 0; i < 4; i++) {
            A[i] = str.charAt(i);
        }
        Arrays.sort(A);

        if (A[0] == A[1] && A[2] == A[3] && A[0] != A[3]) {
            System.out.println("Yes");
        } else { 
            System.out.println("No");
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.next(); str sc.next() sc.next sc int[] A = new int[4]; A new int[4] 4 for (int i = 0; i < 4; i++) {
            A[i] = str.charAt(i);
        } int i = 0; int i = 0; i 0 i < 4 i 4 i++ i++ i {
            A[i] = str.charAt(i);
        } {
            A[i] = str.charAt(i);
        } A[i] = str.charAt(i) A[i] A i str.charAt(i) str.charAt str i Arrays.sort(A) Arrays.sort Arrays A if (A[0] == A[1] && A[2] == A[3] && A[0] != A[3]) {
            System.out.println("Yes");
        } else { 
            System.out.println("No");
        } A[0] == A[1] && A[2] == A[3] && A[0] != A[3] A[0] == A[1] && A[2] == A[3] && A[0] != A[3] A[0] == A[1] A[0] A 0 A[1] A 1 A[2] == A[3] A[2] A 2 A[3] A 3 A[0] != A[3] A[0] A 0 A[3] A 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" String[] args args
import java.util.Scanner;
import java.util.Arrays;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.next();

        int[] A = new int[4];
        for (int i = 0; i < 4; i++) {
            A[i] = str.charAt(i);
        }
        Arrays.sort(A);

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