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

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] S = scanner.next().toCharArray();

			Map<Character, Integer> map = new HashMap<>();

			for (char c : S) {
				map.put(c, map.getOrDefault(c, 0) + 1);
			}

			String ans = "No";
			if (map.size() == 2) {

				if (map.get(S[0]) == 2) {
					ans = "Yes";
				}

			}

			System.out.println(ans);
		}
	}
} 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 scanner = new Scanner(System.in)) {
			char[] S = scanner.next().toCharArray();

			Map<Character, Integer> map = new HashMap<>();

			for (char c : S) {
				map.put(c, map.getOrDefault(c, 0) + 1);
			}

			String ans = "No";
			if (map.size() == 2) {

				if (map.get(S[0]) == 2) {
					ans = "Yes";
				}

			}

			System.out.println(ans);
		}
	}
} Main public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] S = scanner.next().toCharArray();

			Map<Character, Integer> map = new HashMap<>();

			for (char c : S) {
				map.put(c, map.getOrDefault(c, 0) + 1);
			}

			String ans = "No";
			if (map.size() == 2) {

				if (map.get(S[0]) == 2) {
					ans = "Yes";
				}

			}

			System.out.println(ans);
		}
	} main {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] S = scanner.next().toCharArray();

			Map<Character, Integer> map = new HashMap<>();

			for (char c : S) {
				map.put(c, map.getOrDefault(c, 0) + 1);
			}

			String ans = "No";
			if (map.size() == 2) {

				if (map.get(S[0]) == 2) {
					ans = "Yes";
				}

			}

			System.out.println(ans);
		}
	} try (Scanner scanner = new Scanner(System.in)) {
			char[] S = scanner.next().toCharArray();

			Map<Character, Integer> map = new HashMap<>();

			for (char c : S) {
				map.put(c, map.getOrDefault(c, 0) + 1);
			}

			String ans = "No";
			if (map.size() == 2) {

				if (map.get(S[0]) == 2) {
					ans = "Yes";
				}

			}

			System.out.println(ans);
		} {
			char[] S = scanner.next().toCharArray();

			Map<Character, Integer> map = new HashMap<>();

			for (char c : S) {
				map.put(c, map.getOrDefault(c, 0) + 1);
			}

			String ans = "No";
			if (map.size() == 2) {

				if (map.get(S[0]) == 2) {
					ans = "Yes";
				}

			}

			System.out.println(ans);
		} Scanner scanner = new Scanner(System.in) Scanner scanner = new Scanner(System.in) new Scanner(System.in) char[] S = scanner.next().toCharArray(); S scanner.next().toCharArray() scanner.next().toCharArray scanner.next() scanner.next scanner Map<Character, Integer> map = new HashMap<>(); map new HashMap<>() for (char c : S) {
				map.put(c, map.getOrDefault(c, 0) + 1);
			} char c S {
				map.put(c, map.getOrDefault(c, 0) + 1);
			} {
				map.put(c, map.getOrDefault(c, 0) + 1);
			} map.put(c, map.getOrDefault(c, 0) + 1) map.put map c map.getOrDefault(c, 0) + 1 map.getOrDefault(c, 0) map.getOrDefault map c 0 1 String ans = "No"; ans "No" if (map.size() == 2) {

				if (map.get(S[0]) == 2) {
					ans = "Yes";
				}

			} map.size() == 2 map.size() map.size map 2 {

				if (map.get(S[0]) == 2) {
					ans = "Yes";
				}

			} if (map.get(S[0]) == 2) {
					ans = "Yes";
				} map.get(S[0]) == 2 map.get(S[0]) map.get map S[0] S 0 2 {
					ans = "Yes";
				} ans = "Yes" ans "Yes" System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] S = scanner.next().toCharArray();

			Map<Character, Integer> map = new HashMap<>();

			for (char c : S) {
				map.put(c, map.getOrDefault(c, 0) + 1);
			}

			String ans = "No";
			if (map.size() == 2) {

				if (map.get(S[0]) == 2) {
					ans = "Yes";
				}

			}

			System.out.println(ans);
		}
	}
} public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] S = scanner.next().toCharArray();

			Map<Character, Integer> map = new HashMap<>();

			for (char c : S) {
				map.put(c, map.getOrDefault(c, 0) + 1);
			}

			String ans = "No";
			if (map.size() == 2) {

				if (map.get(S[0]) == 2) {
					ans = "Yes";
				}

			}

			System.out.println(ans);
		}
	}
} Main
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] S = scanner.next().toCharArray();

			Map<Character, Integer> map = new HashMap<>();

			for (char c : S) {
				map.put(c, map.getOrDefault(c, 0) + 1);
			}

			String ans = "No";
			if (map.size() == 2) {

				if (map.get(S[0]) == 2) {
					ans = "Yes";
				}

			}

			System.out.println(ans);
		}
	}
}
