
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		Map<Integer, Integer> m = new HashMap<Integer, Integer>();
		for(int i=0; i<s.length(); i++) {
			char c = s.charAt(i);
			m.put(c-'A', m.containsKey(c-'A') ? m.get(c-'A')+1 : 1);
		}
		if(m.size()!=2) {
			System.out.println("No");
			sc.close();
			return;
		}else {
			for(Map.Entry<Integer, Integer> e : m.entrySet()) {
				if(e.getValue() != 2) {
					System.out.println("No");
					sc.close();
					return;
				}
			}
		}
		System.out.println("Yes");
		sc.close();
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		Map<Integer, Integer> m = new HashMap<Integer, Integer>();
		for(int i=0; i<s.length(); i++) {
			char c = s.charAt(i);
			m.put(c-'A', m.containsKey(c-'A') ? m.get(c-'A')+1 : 1);
		}
		if(m.size()!=2) {
			System.out.println("No");
			sc.close();
			return;
		}else {
			for(Map.Entry<Integer, Integer> e : m.entrySet()) {
				if(e.getValue() != 2) {
					System.out.println("No");
					sc.close();
					return;
				}
			}
		}
		System.out.println("Yes");
		sc.close();
	}
} Main public static void main(String[] args) {
		Main main = new Main();
		main.run();
	} main {
		Main main = new Main();
		main.run();
	} Main main = new Main(); main new Main() main.run() main.run main String[] args args public void run() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		Map<Integer, Integer> m = new HashMap<Integer, Integer>();
		for(int i=0; i<s.length(); i++) {
			char c = s.charAt(i);
			m.put(c-'A', m.containsKey(c-'A') ? m.get(c-'A')+1 : 1);
		}
		if(m.size()!=2) {
			System.out.println("No");
			sc.close();
			return;
		}else {
			for(Map.Entry<Integer, Integer> e : m.entrySet()) {
				if(e.getValue() != 2) {
					System.out.println("No");
					sc.close();
					return;
				}
			}
		}
		System.out.println("Yes");
		sc.close();
	} run {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		Map<Integer, Integer> m = new HashMap<Integer, Integer>();
		for(int i=0; i<s.length(); i++) {
			char c = s.charAt(i);
			m.put(c-'A', m.containsKey(c-'A') ? m.get(c-'A')+1 : 1);
		}
		if(m.size()!=2) {
			System.out.println("No");
			sc.close();
			return;
		}else {
			for(Map.Entry<Integer, Integer> e : m.entrySet()) {
				if(e.getValue() != 2) {
					System.out.println("No");
					sc.close();
					return;
				}
			}
		}
		System.out.println("Yes");
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc Map<Integer, Integer> m = new HashMap<Integer, Integer>(); m new HashMap<Integer, Integer>() for(int i=0; i<s.length(); i++) {
			char c = s.charAt(i);
			m.put(c-'A', m.containsKey(c-'A') ? m.get(c-'A')+1 : 1);
		} int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
			char c = s.charAt(i);
			m.put(c-'A', m.containsKey(c-'A') ? m.get(c-'A')+1 : 1);
		} {
			char c = s.charAt(i);
			m.put(c-'A', m.containsKey(c-'A') ? m.get(c-'A')+1 : 1);
		} char c = s.charAt(i); c s.charAt(i) s.charAt s i m.put(c-'A', m.containsKey(c-'A') ? m.get(c-'A')+1 : 1) m.put m c-'A' c 'A' m.containsKey(c-'A') ? m.get(c-'A')+1 : 1 m.containsKey(c-'A') m.containsKey m c-'A' c 'A' m.get(c-'A')+1 m.get(c-'A') m.get m c-'A' c 'A' 1 1 if(m.size()!=2) {
			System.out.println("No");
			sc.close();
			return;
		}else {
			for(Map.Entry<Integer, Integer> e : m.entrySet()) {
				if(e.getValue() != 2) {
					System.out.println("No");
					sc.close();
					return;
				}
			}
		} m.size()!=2 m.size() m.size m 2 {
			System.out.println("No");
			sc.close();
			return;
		} System.out.println("No") System.out.println System.out System System.out "No" sc.close() sc.close sc return; {
			for(Map.Entry<Integer, Integer> e : m.entrySet()) {
				if(e.getValue() != 2) {
					System.out.println("No");
					sc.close();
					return;
				}
			}
		} for(Map.Entry<Integer, Integer> e : m.entrySet()) {
				if(e.getValue() != 2) {
					System.out.println("No");
					sc.close();
					return;
				}
			} Map.Entry<Integer, Integer> e m.entrySet() m.entrySet m {
				if(e.getValue() != 2) {
					System.out.println("No");
					sc.close();
					return;
				}
			} {
				if(e.getValue() != 2) {
					System.out.println("No");
					sc.close();
					return;
				}
			} if(e.getValue() != 2) {
					System.out.println("No");
					sc.close();
					return;
				} e.getValue() != 2 e.getValue() e.getValue e 2 {
					System.out.println("No");
					sc.close();
					return;
				} System.out.println("No") System.out.println System.out System System.out "No" sc.close() sc.close sc return; System.out.println("Yes") System.out.println System.out System System.out "Yes" sc.close() sc.close sc public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		Map<Integer, Integer> m = new HashMap<Integer, Integer>();
		for(int i=0; i<s.length(); i++) {
			char c = s.charAt(i);
			m.put(c-'A', m.containsKey(c-'A') ? m.get(c-'A')+1 : 1);
		}
		if(m.size()!=2) {
			System.out.println("No");
			sc.close();
			return;
		}else {
			for(Map.Entry<Integer, Integer> e : m.entrySet()) {
				if(e.getValue() != 2) {
					System.out.println("No");
					sc.close();
					return;
				}
			}
		}
		System.out.println("Yes");
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		Map<Integer, Integer> m = new HashMap<Integer, Integer>();
		for(int i=0; i<s.length(); i++) {
			char c = s.charAt(i);
			m.put(c-'A', m.containsKey(c-'A') ? m.get(c-'A')+1 : 1);
		}
		if(m.size()!=2) {
			System.out.println("No");
			sc.close();
			return;
		}else {
			for(Map.Entry<Integer, Integer> e : m.entrySet()) {
				if(e.getValue() != 2) {
					System.out.println("No");
					sc.close();
					return;
				}
			}
		}
		System.out.println("Yes");
		sc.close();
	}
} Main

import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		Map<Integer, Integer> m = new HashMap<Integer, Integer>();
		for(int i=0; i<s.length(); i++) {
			char c = s.charAt(i);
			m.put(c-'A', m.containsKey(c-'A') ? m.get(c-'A')+1 : 1);
		}
		if(m.size()!=2) {
			System.out.println("No");
			sc.close();
			return;
		}else {
			for(Map.Entry<Integer, Integer> e : m.entrySet()) {
				if(e.getValue() != 2) {
					System.out.println("No");
					sc.close();
					return;
				}
			}
		}
		System.out.println("Yes");
		sc.close();
	}
}
