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