import java.util.Arrays;
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {
      
         Scanner entrada=new Scanner(System.in);
         int count=0;
         String S=entrada.next();
        int [] x =new int[4];
        
        
       
        for (int i = 0; i <4; i++) {
            x[i]=S.charAt(i);
            
        }
        
        Arrays.sort(x);
        for (int i = 0; i < 3; i++) {
            if(x[i]==x[i+1]){
                count++;
            }
            
        }
       
        if(x[0]==x[1]&&x[2]==x[3]&& count!=3){
            System.out.println("Yes");
        }else if(count==3 || (x[0]!=x[1]&&x[2]!=x[3])||(x[0]==x[1]&&x[2]!=x[3]) ||x[0]!=x[1]&&x[2]==x[3]  ){
            System.out.println("No");
        }
        
    }
    
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
      
         Scanner entrada=new Scanner(System.in);
         int count=0;
         String S=entrada.next();
        int [] x =new int[4];
        
        
       
        for (int i = 0; i <4; i++) {
            x[i]=S.charAt(i);
            
        }
        
        Arrays.sort(x);
        for (int i = 0; i < 3; i++) {
            if(x[i]==x[i+1]){
                count++;
            }
            
        }
       
        if(x[0]==x[1]&&x[2]==x[3]&& count!=3){
            System.out.println("Yes");
        }else if(count==3 || (x[0]!=x[1]&&x[2]!=x[3])||(x[0]==x[1]&&x[2]!=x[3]) ||x[0]!=x[1]&&x[2]==x[3]  ){
            System.out.println("No");
        }
        
    }
    
} Main public static void main(String[] args) {
      
         Scanner entrada=new Scanner(System.in);
         int count=0;
         String S=entrada.next();
        int [] x =new int[4];
        
        
       
        for (int i = 0; i <4; i++) {
            x[i]=S.charAt(i);
            
        }
        
        Arrays.sort(x);
        for (int i = 0; i < 3; i++) {
            if(x[i]==x[i+1]){
                count++;
            }
            
        }
       
        if(x[0]==x[1]&&x[2]==x[3]&& count!=3){
            System.out.println("Yes");
        }else if(count==3 || (x[0]!=x[1]&&x[2]!=x[3])||(x[0]==x[1]&&x[2]!=x[3]) ||x[0]!=x[1]&&x[2]==x[3]  ){
            System.out.println("No");
        }
        
    } main {
      
         Scanner entrada=new Scanner(System.in);
         int count=0;
         String S=entrada.next();
        int [] x =new int[4];
        
        
       
        for (int i = 0; i <4; i++) {
            x[i]=S.charAt(i);
            
        }
        
        Arrays.sort(x);
        for (int i = 0; i < 3; i++) {
            if(x[i]==x[i+1]){
                count++;
            }
            
        }
       
        if(x[0]==x[1]&&x[2]==x[3]&& count!=3){
            System.out.println("Yes");
        }else if(count==3 || (x[0]!=x[1]&&x[2]!=x[3])||(x[0]==x[1]&&x[2]!=x[3]) ||x[0]!=x[1]&&x[2]==x[3]  ){
            System.out.println("No");
        }
        
    } Scanner entrada=new Scanner(System.in); entrada new Scanner(System.in) int count=0; count 0 String S=entrada.next(); S entrada.next() entrada.next entrada int [] x =new int[4]; x new int[4] 4 for (int i = 0; i <4; i++) {
            x[i]=S.charAt(i);
            
        } int i = 0; int i = 0; i 0 i <4 i 4 i++ i++ i {
            x[i]=S.charAt(i);
            
        } {
            x[i]=S.charAt(i);
            
        } x[i]=S.charAt(i) x[i] x i S.charAt(i) S.charAt S i Arrays.sort(x) Arrays.sort Arrays x for (int i = 0; i < 3; i++) {
            if(x[i]==x[i+1]){
                count++;
            }
            
        } int i = 0; int i = 0; i 0 i < 3 i 3 i++ i++ i {
            if(x[i]==x[i+1]){
                count++;
            }
            
        } {
            if(x[i]==x[i+1]){
                count++;
            }
            
        } if(x[i]==x[i+1]){
                count++;
            } x[i]==x[i+1] x[i] x i x[i+1] x i+1 i 1 {
                count++;
            } count++ count if(x[0]==x[1]&&x[2]==x[3]&& count!=3){
            System.out.println("Yes");
        }else if(count==3 || (x[0]!=x[1]&&x[2]!=x[3])||(x[0]==x[1]&&x[2]!=x[3]) ||x[0]!=x[1]&&x[2]==x[3]  ){
            System.out.println("No");
        } x[0]==x[1]&&x[2]==x[3]&& count!=3 x[0]==x[1]&&x[2]==x[3]&& count!=3 x[0]==x[1] x[0] x 0 x[1] x 1 x[2]==x[3] x[2] x 2 x[3] x 3 count!=3 count 3 {
            System.out.println("Yes");
        } System.out.println("Yes") System.out.println System.out System System.out "Yes" if(count==3 || (x[0]!=x[1]&&x[2]!=x[3])||(x[0]==x[1]&&x[2]!=x[3]) ||x[0]!=x[1]&&x[2]==x[3]  ){
            System.out.println("No");
        } count==3 || (x[0]!=x[1]&&x[2]!=x[3])||(x[0]==x[1]&&x[2]!=x[3]) ||x[0]!=x[1]&&x[2]==x[3] (x[0]==x[1]&&x[2]!=x[3]) count==3 || (x[0]!=x[1]&&x[2]!=x[3])||(x[0]==x[1]&&x[2]!=x[3]) ||x[0]!=x[1]&&x[2]==x[3] count==3 count 3 (x[0]!=x[1]&&x[2]!=x[3]) x[0]!=x[1] x[0] x 0 x[1] x 1 x[2]!=x[3] x[2] x 2 x[3] x 3 (x[0]==x[1]&&x[2]!=x[3]) x[0]==x[1] x[0] x 0 x[1] x 1 x[2]!=x[3] x[2] x 2 x[3] x 3 x[0]!=x[1]&&x[2]==x[3] x[0]!=x[1] x[0] x 0 x[1] x 1 x[2]==x[3] x[2] x 2 x[3] x 3 {
            System.out.println("No");
        } System.out.println("No") System.out.println System.out System System.out "No" String[] args args public class Main {

    public static void main(String[] args) {
      
         Scanner entrada=new Scanner(System.in);
         int count=0;
         String S=entrada.next();
        int [] x =new int[4];
        
        
       
        for (int i = 0; i <4; i++) {
            x[i]=S.charAt(i);
            
        }
        
        Arrays.sort(x);
        for (int i = 0; i < 3; i++) {
            if(x[i]==x[i+1]){
                count++;
            }
            
        }
       
        if(x[0]==x[1]&&x[2]==x[3]&& count!=3){
            System.out.println("Yes");
        }else if(count==3 || (x[0]!=x[1]&&x[2]!=x[3])||(x[0]==x[1]&&x[2]!=x[3]) ||x[0]!=x[1]&&x[2]==x[3]  ){
            System.out.println("No");
        }
        
    }
    
} public class Main {

    public static void main(String[] args) {
      
         Scanner entrada=new Scanner(System.in);
         int count=0;
         String S=entrada.next();
        int [] x =new int[4];
        
        
       
        for (int i = 0; i <4; i++) {
            x[i]=S.charAt(i);
            
        }
        
        Arrays.sort(x);
        for (int i = 0; i < 3; i++) {
            if(x[i]==x[i+1]){
                count++;
            }
            
        }
       
        if(x[0]==x[1]&&x[2]==x[3]&& count!=3){
            System.out.println("Yes");
        }else if(count==3 || (x[0]!=x[1]&&x[2]!=x[3])||(x[0]==x[1]&&x[2]!=x[3]) ||x[0]!=x[1]&&x[2]==x[3]  ){
            System.out.println("No");
        }
        
    }
    
} Main
import java.util.Arrays;
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {
      
         Scanner entrada=new Scanner(System.in);
         int count=0;
         String S=entrada.next();
        int [] x =new int[4];
        
        
       
        for (int i = 0; i <4; i++) {
            x[i]=S.charAt(i);
            
        }
        
        Arrays.sort(x);
        for (int i = 0; i < 3; i++) {
            if(x[i]==x[i+1]){
                count++;
            }
            
        }
       
        if(x[0]==x[1]&&x[2]==x[3]&& count!=3){
            System.out.println("Yes");
        }else if(count==3 || (x[0]!=x[1]&&x[2]!=x[3])||(x[0]==x[1]&&x[2]!=x[3]) ||x[0]!=x[1]&&x[2]==x[3]  ){
            System.out.println("No");
        }
        
    }
    
}
