import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scanner = new Scanner(System.in);
		
		String str = scanner.nextLine();
		scanner.close();
		
		if (str.length() != 4) {
			System.out.println("No");
			return;
		}
		
		char[] ar = str.toCharArray();
		Arrays.sort(ar);
		
		if (ar[0] == ar[1] && ar[2] == ar[3] && ar[0] != ar[2] ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scanner = new Scanner(System.in);
		
		String str = scanner.nextLine();
		scanner.close();
		
		if (str.length() != 4) {
			System.out.println("No");
			return;
		}
		
		char[] ar = str.toCharArray();
		Arrays.sort(ar);
		
		if (ar[0] == ar[1] && ar[2] == ar[3] && ar[0] != ar[2] ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scanner = new Scanner(System.in);
		
		String str = scanner.nextLine();
		scanner.close();
		
		if (str.length() != 4) {
			System.out.println("No");
			return;
		}
		
		char[] ar = str.toCharArray();
		Arrays.sort(ar);
		
		if (ar[0] == ar[1] && ar[2] == ar[3] && ar[0] != ar[2] ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	} main {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scanner = new Scanner(System.in);
		
		String str = scanner.nextLine();
		scanner.close();
		
		if (str.length() != 4) {
			System.out.println("No");
			return;
		}
		
		char[] ar = str.toCharArray();
		Arrays.sort(ar);
		
		if (ar[0] == ar[1] && ar[2] == ar[3] && ar[0] != ar[2] ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String str = scanner.nextLine(); str scanner.nextLine() scanner.nextLine scanner scanner.close() scanner.close scanner if (str.length() != 4) {
			System.out.println("No");
			return;
		} str.length() != 4 str.length() str.length str 4 {
			System.out.println("No");
			return;
		} System.out.println("No") System.out.println System.out System System.out "No" return; char[] ar = str.toCharArray(); ar str.toCharArray() str.toCharArray str Arrays.sort(ar) Arrays.sort Arrays ar if (ar[0] == ar[1] && ar[2] == ar[3] && ar[0] != ar[2] ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		} ar[0] == ar[1] && ar[2] == ar[3] && ar[0] != ar[2] ar[0] == ar[1] && ar[2] == ar[3] && ar[0] != ar[2] ar[0] == ar[1] ar[0] ar 0 ar[1] ar 1 ar[2] == ar[3] ar[2] ar 2 ar[3] ar 3 ar[0] != ar[2] ar[0] ar 0 ar[2] ar 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" String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scanner = new Scanner(System.in);
		
		String str = scanner.nextLine();
		scanner.close();
		
		if (str.length() != 4) {
			System.out.println("No");
			return;
		}
		
		char[] ar = str.toCharArray();
		Arrays.sort(ar);
		
		if (ar[0] == ar[1] && ar[2] == ar[3] && ar[0] != ar[2] ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scanner = new Scanner(System.in);
		
		String str = scanner.nextLine();
		scanner.close();
		
		if (str.length() != 4) {
			System.out.println("No");
			return;
		}
		
		char[] ar = str.toCharArray();
		Arrays.sort(ar);
		
		if (ar[0] == ar[1] && ar[2] == ar[3] && ar[0] != ar[2] ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scanner = new Scanner(System.in);
		
		String str = scanner.nextLine();
		scanner.close();
		
		if (str.length() != 4) {
			System.out.println("No");
			return;
		}
		
		char[] ar = str.toCharArray();
		Arrays.sort(ar);
		
		if (ar[0] == ar[1] && ar[2] == ar[3] && ar[0] != ar[2] ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}