import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String S = sc.next();
		char[] c = new char[4];
		
		List<String> list = new ArrayList<>();
        
        for(int i = 0; i < 4; i++){
		    list.add(String.valueOf(S.charAt(i)));
		}
		
		Set<String> set = new HashSet<>(list);
		List<String> list2 = new ArrayList<>(set);
		
		if(list2.size() == 2){
		    System.out.println("Yes");
		} else {
		    System.out.println("No");
		}
        
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String S = sc.next();
		char[] c = new char[4];
		
		List<String> list = new ArrayList<>();
        
        for(int i = 0; i < 4; i++){
		    list.add(String.valueOf(S.charAt(i)));
		}
		
		Set<String> set = new HashSet<>(list);
		List<String> list2 = new ArrayList<>(set);
		
		if(list2.size() == 2){
		    System.out.println("Yes");
		} else {
		    System.out.println("No");
		}
        
    }
} Main public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String S = sc.next();
		char[] c = new char[4];
		
		List<String> list = new ArrayList<>();
        
        for(int i = 0; i < 4; i++){
		    list.add(String.valueOf(S.charAt(i)));
		}
		
		Set<String> set = new HashSet<>(list);
		List<String> list2 = new ArrayList<>(set);
		
		if(list2.size() == 2){
		    System.out.println("Yes");
		} else {
		    System.out.println("No");
		}
        
    } main {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String S = sc.next();
		char[] c = new char[4];
		
		List<String> list = new ArrayList<>();
        
        for(int i = 0; i < 4; i++){
		    list.add(String.valueOf(S.charAt(i)));
		}
		
		Set<String> set = new HashSet<>(list);
		List<String> list2 = new ArrayList<>(set);
		
		if(list2.size() == 2){
		    System.out.println("Yes");
		} 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[] c = new char[4]; c new char[4] 4 List<String> list = new ArrayList<>(); list new ArrayList<>() for(int i = 0; i < 4; i++){
		    list.add(String.valueOf(S.charAt(i)));
		} int i = 0; int i = 0; i 0 i < 4 i 4 i++ i++ i {
		    list.add(String.valueOf(S.charAt(i)));
		} {
		    list.add(String.valueOf(S.charAt(i)));
		} list.add(String.valueOf(S.charAt(i))) list.add list String.valueOf(S.charAt(i)) String.valueOf String S.charAt(i) S.charAt S i Set<String> set = new HashSet<>(list); set new HashSet<>(list) List<String> list2 = new ArrayList<>(set); list2 new ArrayList<>(set) if(list2.size() == 2){
		    System.out.println("Yes");
		} else {
		    System.out.println("No");
		} list2.size() == 2 list2.size() list2.size list2 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" String[] args args public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String S = sc.next();
		char[] c = new char[4];
		
		List<String> list = new ArrayList<>();
        
        for(int i = 0; i < 4; i++){
		    list.add(String.valueOf(S.charAt(i)));
		}
		
		Set<String> set = new HashSet<>(list);
		List<String> list2 = new ArrayList<>(set);
		
		if(list2.size() == 2){
		    System.out.println("Yes");
		} else {
		    System.out.println("No");
		}
        
    }
} public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String S = sc.next();
		char[] c = new char[4];
		
		List<String> list = new ArrayList<>();
        
        for(int i = 0; i < 4; i++){
		    list.add(String.valueOf(S.charAt(i)));
		}
		
		Set<String> set = new HashSet<>(list);
		List<String> list2 = new ArrayList<>(set);
		
		if(list2.size() == 2){
		    System.out.println("Yes");
		} else {
		    System.out.println("No");
		}
        
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String S = sc.next();
		char[] c = new char[4];
		
		List<String> list = new ArrayList<>();
        
        for(int i = 0; i < 4; i++){
		    list.add(String.valueOf(S.charAt(i)));
		}
		
		Set<String> set = new HashSet<>(list);
		List<String> list2 = new ArrayList<>(set);
		
		if(list2.size() == 2){
		    System.out.println("Yes");
		} else {
		    System.out.println("No");
		}
        
    }
}