import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void a() {
		String s = sc.next();
		char c1 = s.charAt(0),c2 = 0;
		int c1cnt = 1,c2cnt = 0;
		for(int i = 1;i < s.length();i ++) {
			char c = s.charAt(i);
			if(c == c1) c1cnt++;
			else if(c != c2) {
				c2cnt = 1;
				c2 = c;
			}
			else if(c == c2) c2cnt++;
		}
		if(c1cnt == 2 && c2cnt == 2) System.out.println("Yes");
		else System.out.println("No");
	}
	public static void main(String[] args) {
		new Main().a();
	}

}


 import java.util.Scanner; Scanner java.util public class Main {
	Scanner sc = new Scanner(System.in);

	void a() {
		String s = sc.next();
		char c1 = s.charAt(0),c2 = 0;
		int c1cnt = 1,c2cnt = 0;
		for(int i = 1;i < s.length();i ++) {
			char c = s.charAt(i);
			if(c == c1) c1cnt++;
			else if(c != c2) {
				c2cnt = 1;
				c2 = c;
			}
			else if(c == c2) c2cnt++;
		}
		if(c1cnt == 2 && c2cnt == 2) System.out.println("Yes");
		else System.out.println("No");
	}
	public static void main(String[] args) {
		new Main().a();
	}

} Main Scanner sc = new Scanner(System.in); sc new Scanner(System.in) void a() {
		String s = sc.next();
		char c1 = s.charAt(0),c2 = 0;
		int c1cnt = 1,c2cnt = 0;
		for(int i = 1;i < s.length();i ++) {
			char c = s.charAt(i);
			if(c == c1) c1cnt++;
			else if(c != c2) {
				c2cnt = 1;
				c2 = c;
			}
			else if(c == c2) c2cnt++;
		}
		if(c1cnt == 2 && c2cnt == 2) System.out.println("Yes");
		else System.out.println("No");
	} a {
		String s = sc.next();
		char c1 = s.charAt(0),c2 = 0;
		int c1cnt = 1,c2cnt = 0;
		for(int i = 1;i < s.length();i ++) {
			char c = s.charAt(i);
			if(c == c1) c1cnt++;
			else if(c != c2) {
				c2cnt = 1;
				c2 = c;
			}
			else if(c == c2) c2cnt++;
		}
		if(c1cnt == 2 && c2cnt == 2) System.out.println("Yes");
		else System.out.println("No");
	} String s = sc.next(); s sc.next() sc.next sc char c1 = s.charAt(0) c1 s.charAt(0) s.charAt s 0 c2 = 0; c2 0 int c1cnt = 1 c1cnt 1 c2cnt = 0; c2cnt 0 for(int i = 1;i < s.length();i ++) {
			char c = s.charAt(i);
			if(c == c1) c1cnt++;
			else if(c != c2) {
				c2cnt = 1;
				c2 = c;
			}
			else if(c == c2) c2cnt++;
		} int i = 1; int i = 1; i 1 i < s.length() i s.length() s.length s i ++ i ++ i {
			char c = s.charAt(i);
			if(c == c1) c1cnt++;
			else if(c != c2) {
				c2cnt = 1;
				c2 = c;
			}
			else if(c == c2) c2cnt++;
		} {
			char c = s.charAt(i);
			if(c == c1) c1cnt++;
			else if(c != c2) {
				c2cnt = 1;
				c2 = c;
			}
			else if(c == c2) c2cnt++;
		} char c = s.charAt(i); c s.charAt(i) s.charAt s i if(c == c1) c1cnt++;
			else if(c != c2) {
				c2cnt = 1;
				c2 = c;
			}
			else if(c == c2) c2cnt++; c == c1 c c1 c1cnt++ c1cnt if(c != c2) {
				c2cnt = 1;
				c2 = c;
			}
			else if(c == c2) c2cnt++; c != c2 c c2 {
				c2cnt = 1;
				c2 = c;
			} c2cnt = 1 c2cnt 1 c2 = c c2 c if(c == c2) c2cnt++; c == c2 c c2 c2cnt++ c2cnt if(c1cnt == 2 && c2cnt == 2) System.out.println("Yes");
		else System.out.println("No"); c1cnt == 2 && c2cnt == 2 c1cnt == 2 c1cnt 2 c2cnt == 2 c2cnt 2 System.out.println("Yes") System.out.println System.out System System.out "Yes" System.out.println("No") System.out.println System.out System System.out "No" public static void main(String[] args) {
		new Main().a();
	} main {
		new Main().a();
	} new Main().a() new Main().a new Main() String[] args args public class Main {
	Scanner sc = new Scanner(System.in);

	void a() {
		String s = sc.next();
		char c1 = s.charAt(0),c2 = 0;
		int c1cnt = 1,c2cnt = 0;
		for(int i = 1;i < s.length();i ++) {
			char c = s.charAt(i);
			if(c == c1) c1cnt++;
			else if(c != c2) {
				c2cnt = 1;
				c2 = c;
			}
			else if(c == c2) c2cnt++;
		}
		if(c1cnt == 2 && c2cnt == 2) System.out.println("Yes");
		else System.out.println("No");
	}
	public static void main(String[] args) {
		new Main().a();
	}

} public class Main {
	Scanner sc = new Scanner(System.in);

	void a() {
		String s = sc.next();
		char c1 = s.charAt(0),c2 = 0;
		int c1cnt = 1,c2cnt = 0;
		for(int i = 1;i < s.length();i ++) {
			char c = s.charAt(i);
			if(c == c1) c1cnt++;
			else if(c != c2) {
				c2cnt = 1;
				c2 = c;
			}
			else if(c == c2) c2cnt++;
		}
		if(c1cnt == 2 && c2cnt == 2) System.out.println("Yes");
		else System.out.println("No");
	}
	public static void main(String[] args) {
		new Main().a();
	}

} Main
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void a() {
		String s = sc.next();
		char c1 = s.charAt(0),c2 = 0;
		int c1cnt = 1,c2cnt = 0;
		for(int i = 1;i < s.length();i ++) {
			char c = s.charAt(i);
			if(c == c1) c1cnt++;
			else if(c != c2) {
				c2cnt = 1;
				c2 = c;
			}
			else if(c == c2) c2cnt++;
		}
		if(c1cnt == 2 && c2cnt == 2) System.out.println("Yes");
		else System.out.println("No");
	}
	public static void main(String[] args) {
		new Main().a();
	}

}



