
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int first = 0;
		int second = 0;
		char firstChar = 0;
		char secondChar = 0;
		for(int i = 0 ; i < 4 ; i++) {
			char c = s.charAt(i);
			if(firstChar == 0) {
				firstChar = c;
				first++;
			} else if(c != firstChar && secondChar == 0) {
				secondChar = c;
				second++;
			} else if(c == firstChar) {
				first++;
			} else if(c == secondChar) {
				second++;
			}
		}
		if(first == 2 && second == 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();

	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int first = 0;
		int second = 0;
		char firstChar = 0;
		char secondChar = 0;
		for(int i = 0 ; i < 4 ; i++) {
			char c = s.charAt(i);
			if(firstChar == 0) {
				firstChar = c;
				first++;
			} else if(c != firstChar && secondChar == 0) {
				secondChar = c;
				second++;
			} else if(c == firstChar) {
				first++;
			} else if(c == secondChar) {
				second++;
			}
		}
		if(first == 2 && second == 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();

	}

} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int first = 0;
		int second = 0;
		char firstChar = 0;
		char secondChar = 0;
		for(int i = 0 ; i < 4 ; i++) {
			char c = s.charAt(i);
			if(firstChar == 0) {
				firstChar = c;
				first++;
			} else if(c != firstChar && secondChar == 0) {
				secondChar = c;
				second++;
			} else if(c == firstChar) {
				first++;
			} else if(c == secondChar) {
				second++;
			}
		}
		if(first == 2 && second == 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();

	} main {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int first = 0;
		int second = 0;
		char firstChar = 0;
		char secondChar = 0;
		for(int i = 0 ; i < 4 ; i++) {
			char c = s.charAt(i);
			if(firstChar == 0) {
				firstChar = c;
				first++;
			} else if(c != firstChar && secondChar == 0) {
				secondChar = c;
				second++;
			} else if(c == firstChar) {
				first++;
			} else if(c == secondChar) {
				second++;
			}
		}
		if(first == 2 && second == 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int first = 0; first 0 int second = 0; second 0 char firstChar = 0; firstChar 0 char secondChar = 0; secondChar 0 for(int i = 0 ; i < 4 ; i++) {
			char c = s.charAt(i);
			if(firstChar == 0) {
				firstChar = c;
				first++;
			} else if(c != firstChar && secondChar == 0) {
				secondChar = c;
				second++;
			} else if(c == firstChar) {
				first++;
			} else if(c == secondChar) {
				second++;
			}
		} int i = 0 ; int i = 0 ; i 0 i < 4 i 4 i++ i++ i {
			char c = s.charAt(i);
			if(firstChar == 0) {
				firstChar = c;
				first++;
			} else if(c != firstChar && secondChar == 0) {
				secondChar = c;
				second++;
			} else if(c == firstChar) {
				first++;
			} else if(c == secondChar) {
				second++;
			}
		} {
			char c = s.charAt(i);
			if(firstChar == 0) {
				firstChar = c;
				first++;
			} else if(c != firstChar && secondChar == 0) {
				secondChar = c;
				second++;
			} else if(c == firstChar) {
				first++;
			} else if(c == secondChar) {
				second++;
			}
		} char c = s.charAt(i); c s.charAt(i) s.charAt s i if(firstChar == 0) {
				firstChar = c;
				first++;
			} else if(c != firstChar && secondChar == 0) {
				secondChar = c;
				second++;
			} else if(c == firstChar) {
				first++;
			} else if(c == secondChar) {
				second++;
			} firstChar == 0 firstChar 0 {
				firstChar = c;
				first++;
			} firstChar = c firstChar c first++ first if(c != firstChar && secondChar == 0) {
				secondChar = c;
				second++;
			} else if(c == firstChar) {
				first++;
			} else if(c == secondChar) {
				second++;
			} c != firstChar && secondChar == 0 c != firstChar c firstChar secondChar == 0 secondChar 0 {
				secondChar = c;
				second++;
			} secondChar = c secondChar c second++ second if(c == firstChar) {
				first++;
			} else if(c == secondChar) {
				second++;
			} c == firstChar c firstChar {
				first++;
			} first++ first if(c == secondChar) {
				second++;
			} c == secondChar c secondChar {
				second++;
			} second++ second if(first == 2 && second == 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		} first == 2 && second == 2 first == 2 first 2 second == 2 second 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" sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int first = 0;
		int second = 0;
		char firstChar = 0;
		char secondChar = 0;
		for(int i = 0 ; i < 4 ; i++) {
			char c = s.charAt(i);
			if(firstChar == 0) {
				firstChar = c;
				first++;
			} else if(c != firstChar && secondChar == 0) {
				secondChar = c;
				second++;
			} else if(c == firstChar) {
				first++;
			} else if(c == secondChar) {
				second++;
			}
		}
		if(first == 2 && second == 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();

	}

} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int first = 0;
		int second = 0;
		char firstChar = 0;
		char secondChar = 0;
		for(int i = 0 ; i < 4 ; i++) {
			char c = s.charAt(i);
			if(firstChar == 0) {
				firstChar = c;
				first++;
			} else if(c != firstChar && secondChar == 0) {
				secondChar = c;
				second++;
			} else if(c == firstChar) {
				first++;
			} else if(c == secondChar) {
				second++;
			}
		}
		if(first == 2 && second == 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();

	}

} Main

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int first = 0;
		int second = 0;
		char firstChar = 0;
		char secondChar = 0;
		for(int i = 0 ; i < 4 ; i++) {
			char c = s.charAt(i);
			if(firstChar == 0) {
				firstChar = c;
				first++;
			} else if(c != firstChar && secondChar == 0) {
				secondChar = c;
				second++;
			} else if(c == firstChar) {
				first++;
			} else if(c == secondChar) {
				second++;
			}
		}
		if(first == 2 && second == 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();

	}

}
