import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int[] count = new int[4];
		for(int i=0; i<4; i++){
			if(s.charAt(i) == s.charAt(0)){
				count[0]++;
			}else if(s.charAt(i) == s.charAt(1)){
				count[1]++;
			}else if(s.charAt(i) == s.charAt(2)){
				count[2]++;
			}else if(s.charAt(i) == s.charAt(3)){
				count[3]++;
			}
		}
		Arrays.sort(count);
		System.out.println(count[0] == 0 && count[1] == 0 && count[2] == 2 && count[3] == 2 ? "Yes" : "No");
	}
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int[] count = new int[4];
		for(int i=0; i<4; i++){
			if(s.charAt(i) == s.charAt(0)){
				count[0]++;
			}else if(s.charAt(i) == s.charAt(1)){
				count[1]++;
			}else if(s.charAt(i) == s.charAt(2)){
				count[2]++;
			}else if(s.charAt(i) == s.charAt(3)){
				count[3]++;
			}
		}
		Arrays.sort(count);
		System.out.println(count[0] == 0 && count[1] == 0 && count[2] == 2 && count[3] == 2 ? "Yes" : "No");
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int[] count = new int[4];
		for(int i=0; i<4; i++){
			if(s.charAt(i) == s.charAt(0)){
				count[0]++;
			}else if(s.charAt(i) == s.charAt(1)){
				count[1]++;
			}else if(s.charAt(i) == s.charAt(2)){
				count[2]++;
			}else if(s.charAt(i) == s.charAt(3)){
				count[3]++;
			}
		}
		Arrays.sort(count);
		System.out.println(count[0] == 0 && count[1] == 0 && count[2] == 2 && count[3] == 2 ? "Yes" : "No");
	} main {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int[] count = new int[4];
		for(int i=0; i<4; i++){
			if(s.charAt(i) == s.charAt(0)){
				count[0]++;
			}else if(s.charAt(i) == s.charAt(1)){
				count[1]++;
			}else if(s.charAt(i) == s.charAt(2)){
				count[2]++;
			}else if(s.charAt(i) == s.charAt(3)){
				count[3]++;
			}
		}
		Arrays.sort(count);
		System.out.println(count[0] == 0 && count[1] == 0 && count[2] == 2 && count[3] == 2 ? "Yes" : "No");
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int[] count = new int[4]; count new int[4] 4 for(int i=0; i<4; i++){
			if(s.charAt(i) == s.charAt(0)){
				count[0]++;
			}else if(s.charAt(i) == s.charAt(1)){
				count[1]++;
			}else if(s.charAt(i) == s.charAt(2)){
				count[2]++;
			}else if(s.charAt(i) == s.charAt(3)){
				count[3]++;
			}
		} int i=0; int i=0; i 0 i<4 i 4 i++ i++ i {
			if(s.charAt(i) == s.charAt(0)){
				count[0]++;
			}else if(s.charAt(i) == s.charAt(1)){
				count[1]++;
			}else if(s.charAt(i) == s.charAt(2)){
				count[2]++;
			}else if(s.charAt(i) == s.charAt(3)){
				count[3]++;
			}
		} {
			if(s.charAt(i) == s.charAt(0)){
				count[0]++;
			}else if(s.charAt(i) == s.charAt(1)){
				count[1]++;
			}else if(s.charAt(i) == s.charAt(2)){
				count[2]++;
			}else if(s.charAt(i) == s.charAt(3)){
				count[3]++;
			}
		} if(s.charAt(i) == s.charAt(0)){
				count[0]++;
			}else if(s.charAt(i) == s.charAt(1)){
				count[1]++;
			}else if(s.charAt(i) == s.charAt(2)){
				count[2]++;
			}else if(s.charAt(i) == s.charAt(3)){
				count[3]++;
			} s.charAt(i) == s.charAt(0) s.charAt(i) s.charAt s i s.charAt(0) s.charAt s 0 {
				count[0]++;
			} count[0]++ count[0] count 0 if(s.charAt(i) == s.charAt(1)){
				count[1]++;
			}else if(s.charAt(i) == s.charAt(2)){
				count[2]++;
			}else if(s.charAt(i) == s.charAt(3)){
				count[3]++;
			} s.charAt(i) == s.charAt(1) s.charAt(i) s.charAt s i s.charAt(1) s.charAt s 1 {
				count[1]++;
			} count[1]++ count[1] count 1 if(s.charAt(i) == s.charAt(2)){
				count[2]++;
			}else if(s.charAt(i) == s.charAt(3)){
				count[3]++;
			} s.charAt(i) == s.charAt(2) s.charAt(i) s.charAt s i s.charAt(2) s.charAt s 2 {
				count[2]++;
			} count[2]++ count[2] count 2 if(s.charAt(i) == s.charAt(3)){
				count[3]++;
			} s.charAt(i) == s.charAt(3) s.charAt(i) s.charAt s i s.charAt(3) s.charAt s 3 {
				count[3]++;
			} count[3]++ count[3] count 3 Arrays.sort(count) Arrays.sort Arrays count System.out.println(count[0] == 0 && count[1] == 0 && count[2] == 2 && count[3] == 2 ? "Yes" : "No") System.out.println System.out System System.out count[0] == 0 && count[1] == 0 && count[2] == 2 && count[3] == 2 ? "Yes" : "No" count[0] == 0 && count[1] == 0 && count[2] == 2 && count[3] == 2 count[2] == 2 count[0] == 0 && count[1] == 0 && count[2] == 2 && count[3] == 2 count[0] == 0 count[0] count 0 0 count[1] == 0 count[1] count 1 0 count[2] == 2 count[2] count 2 2 count[3] == 2 count[3] count 3 2 "Yes" "No" String[] args args public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int[] count = new int[4];
		for(int i=0; i<4; i++){
			if(s.charAt(i) == s.charAt(0)){
				count[0]++;
			}else if(s.charAt(i) == s.charAt(1)){
				count[1]++;
			}else if(s.charAt(i) == s.charAt(2)){
				count[2]++;
			}else if(s.charAt(i) == s.charAt(3)){
				count[3]++;
			}
		}
		Arrays.sort(count);
		System.out.println(count[0] == 0 && count[1] == 0 && count[2] == 2 && count[3] == 2 ? "Yes" : "No");
	}
} public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int[] count = new int[4];
		for(int i=0; i<4; i++){
			if(s.charAt(i) == s.charAt(0)){
				count[0]++;
			}else if(s.charAt(i) == s.charAt(1)){
				count[1]++;
			}else if(s.charAt(i) == s.charAt(2)){
				count[2]++;
			}else if(s.charAt(i) == s.charAt(3)){
				count[3]++;
			}
		}
		Arrays.sort(count);
		System.out.println(count[0] == 0 && count[1] == 0 && count[2] == 2 && count[3] == 2 ? "Yes" : "No");
	}
} Main
import java.util.*;
//import java.util.stream.Collectors;

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