import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			Map<Character, Integer> map = new HashMap<>();
			for (char c : sc.next().toCharArray()) {
				map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1);
			}
			if (map.size() == 2) {
				for (int cnt : map.values()) {
					if (cnt != 2) {
						System.out.println("No");
						return;
					}
				}
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
	}
} import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			Map<Character, Integer> map = new HashMap<>();
			for (char c : sc.next().toCharArray()) {
				map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1);
			}
			if (map.size() == 2) {
				for (int cnt : map.values()) {
					if (cnt != 2) {
						System.out.println("No");
						return;
					}
				}
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
	}
} Main public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			Map<Character, Integer> map = new HashMap<>();
			for (char c : sc.next().toCharArray()) {
				map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1);
			}
			if (map.size() == 2) {
				for (int cnt : map.values()) {
					if (cnt != 2) {
						System.out.println("No");
						return;
					}
				}
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
	} main {
		try (Scanner sc = new Scanner(System.in)) {
			Map<Character, Integer> map = new HashMap<>();
			for (char c : sc.next().toCharArray()) {
				map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1);
			}
			if (map.size() == 2) {
				for (int cnt : map.values()) {
					if (cnt != 2) {
						System.out.println("No");
						return;
					}
				}
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
	} try (Scanner sc = new Scanner(System.in)) {
			Map<Character, Integer> map = new HashMap<>();
			for (char c : sc.next().toCharArray()) {
				map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1);
			}
			if (map.size() == 2) {
				for (int cnt : map.values()) {
					if (cnt != 2) {
						System.out.println("No");
						return;
					}
				}
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		} {
			Map<Character, Integer> map = new HashMap<>();
			for (char c : sc.next().toCharArray()) {
				map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1);
			}
			if (map.size() == 2) {
				for (int cnt : map.values()) {
					if (cnt != 2) {
						System.out.println("No");
						return;
					}
				}
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) Map<Character, Integer> map = new HashMap<>(); map new HashMap<>() for (char c : sc.next().toCharArray()) {
				map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1);
			} char c sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc {
				map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1);
			} {
				map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1);
			} map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1) map.put map c map.containsKey(c) ? map.get(c) + 1 : 1 map.containsKey(c) map.containsKey map c map.get(c) + 1 map.get(c) map.get map c 1 1 if (map.size() == 2) {
				for (int cnt : map.values()) {
					if (cnt != 2) {
						System.out.println("No");
						return;
					}
				}
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			} map.size() == 2 map.size() map.size map 2 {
				for (int cnt : map.values()) {
					if (cnt != 2) {
						System.out.println("No");
						return;
					}
				}
				System.out.println("Yes");
			} for (int cnt : map.values()) {
					if (cnt != 2) {
						System.out.println("No");
						return;
					}
				} int cnt map.values() map.values map {
					if (cnt != 2) {
						System.out.println("No");
						return;
					}
				} {
					if (cnt != 2) {
						System.out.println("No");
						return;
					}
				} if (cnt != 2) {
						System.out.println("No");
						return;
					} cnt != 2 cnt 2 {
						System.out.println("No");
						return;
					} System.out.println("No") System.out.println System.out System System.out "No" return; 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) {
		try (Scanner sc = new Scanner(System.in)) {
			Map<Character, Integer> map = new HashMap<>();
			for (char c : sc.next().toCharArray()) {
				map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1);
			}
			if (map.size() == 2) {
				for (int cnt : map.values()) {
					if (cnt != 2) {
						System.out.println("No");
						return;
					}
				}
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
	}
} public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			Map<Character, Integer> map = new HashMap<>();
			for (char c : sc.next().toCharArray()) {
				map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1);
			}
			if (map.size() == 2) {
				for (int cnt : map.values()) {
					if (cnt != 2) {
						System.out.println("No");
						return;
					}
				}
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
	}
} Main
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			Map<Character, Integer> map = new HashMap<>();
			for (char c : sc.next().toCharArray()) {
				map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1);
			}
			if (map.size() == 2) {
				for (int cnt : map.values()) {
					if (cnt != 2) {
						System.out.println("No");
						return;
					}
				}
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
	}
}