import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		String s = in.next();
		char[] targ = s.toCharArray();
		HashMap<Character, Integer> map = new HashMap<>();

		for ( int i = 0; i < targ.length; i++ ) {
			if ( !map.containsKey(targ[i]) ) {
				map.put(targ[i], 1);
			} else {
				map.put(targ[i], map.get(targ[i]) + 1);
			}
		}

		boolean ok = true;

		for ( Entry<Character, Integer> c : map.entrySet() ) {
			if ( c.getValue() != 2 ) {
				ok = false;
				break;
			}
		}

		if ( ok && map.size() == 2 ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		in.close();
	}
} import java.util.HashMap; HashMap java.util import java.util.Map.Entry; Entry java.util.Map import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		String s = in.next();
		char[] targ = s.toCharArray();
		HashMap<Character, Integer> map = new HashMap<>();

		for ( int i = 0; i < targ.length; i++ ) {
			if ( !map.containsKey(targ[i]) ) {
				map.put(targ[i], 1);
			} else {
				map.put(targ[i], map.get(targ[i]) + 1);
			}
		}

		boolean ok = true;

		for ( Entry<Character, Integer> c : map.entrySet() ) {
			if ( c.getValue() != 2 ) {
				ok = false;
				break;
			}
		}

		if ( ok && map.size() == 2 ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		in.close();
	}
} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		String s = in.next();
		char[] targ = s.toCharArray();
		HashMap<Character, Integer> map = new HashMap<>();

		for ( int i = 0; i < targ.length; i++ ) {
			if ( !map.containsKey(targ[i]) ) {
				map.put(targ[i], 1);
			} else {
				map.put(targ[i], map.get(targ[i]) + 1);
			}
		}

		boolean ok = true;

		for ( Entry<Character, Integer> c : map.entrySet() ) {
			if ( c.getValue() != 2 ) {
				ok = false;
				break;
			}
		}

		if ( ok && map.size() == 2 ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		in.close();
	} main {
		Scanner in = new Scanner(System.in);

		String s = in.next();
		char[] targ = s.toCharArray();
		HashMap<Character, Integer> map = new HashMap<>();

		for ( int i = 0; i < targ.length; i++ ) {
			if ( !map.containsKey(targ[i]) ) {
				map.put(targ[i], 1);
			} else {
				map.put(targ[i], map.get(targ[i]) + 1);
			}
		}

		boolean ok = true;

		for ( Entry<Character, Integer> c : map.entrySet() ) {
			if ( c.getValue() != 2 ) {
				ok = false;
				break;
			}
		}

		if ( ok && map.size() == 2 ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		in.close();
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) String s = in.next(); s in.next() in.next in char[] targ = s.toCharArray(); targ s.toCharArray() s.toCharArray s HashMap<Character, Integer> map = new HashMap<>(); map new HashMap<>() for ( int i = 0; i < targ.length; i++ ) {
			if ( !map.containsKey(targ[i]) ) {
				map.put(targ[i], 1);
			} else {
				map.put(targ[i], map.get(targ[i]) + 1);
			}
		} int i = 0; int i = 0; i 0 i < targ.length i targ.length targ targ.length i++ i++ i {
			if ( !map.containsKey(targ[i]) ) {
				map.put(targ[i], 1);
			} else {
				map.put(targ[i], map.get(targ[i]) + 1);
			}
		} {
			if ( !map.containsKey(targ[i]) ) {
				map.put(targ[i], 1);
			} else {
				map.put(targ[i], map.get(targ[i]) + 1);
			}
		} if ( !map.containsKey(targ[i]) ) {
				map.put(targ[i], 1);
			} else {
				map.put(targ[i], map.get(targ[i]) + 1);
			} !map.containsKey(targ[i]) map.containsKey(targ[i]) map.containsKey map targ[i] targ i {
				map.put(targ[i], 1);
			} map.put(targ[i], 1) map.put map targ[i] targ i 1 {
				map.put(targ[i], map.get(targ[i]) + 1);
			} map.put(targ[i], map.get(targ[i]) + 1) map.put map targ[i] targ i map.get(targ[i]) + 1 map.get(targ[i]) map.get map targ[i] targ i 1 boolean ok = true; ok true for ( Entry<Character, Integer> c : map.entrySet() ) {
			if ( c.getValue() != 2 ) {
				ok = false;
				break;
			}
		} Entry<Character, Integer> c map.entrySet() map.entrySet map {
			if ( c.getValue() != 2 ) {
				ok = false;
				break;
			}
		} {
			if ( c.getValue() != 2 ) {
				ok = false;
				break;
			}
		} if ( c.getValue() != 2 ) {
				ok = false;
				break;
			} c.getValue() != 2 c.getValue() c.getValue c 2 {
				ok = false;
				break;
			} ok = false ok false break; if ( ok && map.size() == 2 ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		} ok && map.size() == 2 ok map.size() == 2 map.size() map.size map 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" in.close() in.close in String[] args args public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		String s = in.next();
		char[] targ = s.toCharArray();
		HashMap<Character, Integer> map = new HashMap<>();

		for ( int i = 0; i < targ.length; i++ ) {
			if ( !map.containsKey(targ[i]) ) {
				map.put(targ[i], 1);
			} else {
				map.put(targ[i], map.get(targ[i]) + 1);
			}
		}

		boolean ok = true;

		for ( Entry<Character, Integer> c : map.entrySet() ) {
			if ( c.getValue() != 2 ) {
				ok = false;
				break;
			}
		}

		if ( ok && map.size() == 2 ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		in.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		String s = in.next();
		char[] targ = s.toCharArray();
		HashMap<Character, Integer> map = new HashMap<>();

		for ( int i = 0; i < targ.length; i++ ) {
			if ( !map.containsKey(targ[i]) ) {
				map.put(targ[i], 1);
			} else {
				map.put(targ[i], map.get(targ[i]) + 1);
			}
		}

		boolean ok = true;

		for ( Entry<Character, Integer> c : map.entrySet() ) {
			if ( c.getValue() != 2 ) {
				ok = false;
				break;
			}
		}

		if ( ok && map.size() == 2 ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		in.close();
	}
} Main
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		String s = in.next();
		char[] targ = s.toCharArray();
		HashMap<Character, Integer> map = new HashMap<>();

		for ( int i = 0; i < targ.length; i++ ) {
			if ( !map.containsKey(targ[i]) ) {
				map.put(targ[i], 1);
			} else {
				map.put(targ[i], map.get(targ[i]) + 1);
			}
		}

		boolean ok = true;

		for ( Entry<Character, Integer> c : map.entrySet() ) {
			if ( c.getValue() != 2 ) {
				ok = false;
				break;
			}
		}

		if ( ok && map.size() == 2 ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		in.close();
	}
}
