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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		//String t= sc.next();
		String[] buff= {"","","",""};
		//int n = sc.nextInt();
		//int m = sc.nextInt();
		//int k = sc.nextInt();
		long count=0,flag=0;
		long count1=0,count2=0;
		int count3=0;
		int[] array = new int[3];
		/*array[0]=n-m;
		array[1]=n*m;
		array[2]=n+m;*/
		Arrays.sort(array);

		for(int i=0;i<4;i++) {
			buff[i]=s.substring(i,i+1);
		}

		if(buff[0].equals(buff[1])&&!buff[1].equals(buff[2])&&buff[2].equals(buff[3])) {
			System.out.println("Yes");
		}else if(buff[0].equals(buff[3])&&buff[1].equals(buff[2])&&!buff[0].equals(buff[1])){
			System.out.println("Yes");
		}else if(!buff[0].equals(buff[1])&&!buff[2].equals(buff[3])&&buff[0].equals(buff[2])&&buff[1].equals(buff[3])){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

		//System.out.println(n*n);
	}
}

 import java.util.Arrays; Arrays java.util 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();
		//String t= sc.next();
		String[] buff= {"","","",""};
		//int n = sc.nextInt();
		//int m = sc.nextInt();
		//int k = sc.nextInt();
		long count=0,flag=0;
		long count1=0,count2=0;
		int count3=0;
		int[] array = new int[3];
		/*array[0]=n-m;
		array[1]=n*m;
		array[2]=n+m;*/
		Arrays.sort(array);

		for(int i=0;i<4;i++) {
			buff[i]=s.substring(i,i+1);
		}

		if(buff[0].equals(buff[1])&&!buff[1].equals(buff[2])&&buff[2].equals(buff[3])) {
			System.out.println("Yes");
		}else if(buff[0].equals(buff[3])&&buff[1].equals(buff[2])&&!buff[0].equals(buff[1])){
			System.out.println("Yes");
		}else if(!buff[0].equals(buff[1])&&!buff[2].equals(buff[3])&&buff[0].equals(buff[2])&&buff[1].equals(buff[3])){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

		//System.out.println(n*n);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		//String t= sc.next();
		String[] buff= {"","","",""};
		//int n = sc.nextInt();
		//int m = sc.nextInt();
		//int k = sc.nextInt();
		long count=0,flag=0;
		long count1=0,count2=0;
		int count3=0;
		int[] array = new int[3];
		/*array[0]=n-m;
		array[1]=n*m;
		array[2]=n+m;*/
		Arrays.sort(array);

		for(int i=0;i<4;i++) {
			buff[i]=s.substring(i,i+1);
		}

		if(buff[0].equals(buff[1])&&!buff[1].equals(buff[2])&&buff[2].equals(buff[3])) {
			System.out.println("Yes");
		}else if(buff[0].equals(buff[3])&&buff[1].equals(buff[2])&&!buff[0].equals(buff[1])){
			System.out.println("Yes");
		}else if(!buff[0].equals(buff[1])&&!buff[2].equals(buff[3])&&buff[0].equals(buff[2])&&buff[1].equals(buff[3])){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

		//System.out.println(n*n);
	} main {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		//String t= sc.next();
		String[] buff= {"","","",""};
		//int n = sc.nextInt();
		//int m = sc.nextInt();
		//int k = sc.nextInt();
		long count=0,flag=0;
		long count1=0,count2=0;
		int count3=0;
		int[] array = new int[3];
		/*array[0]=n-m;
		array[1]=n*m;
		array[2]=n+m;*/
		Arrays.sort(array);

		for(int i=0;i<4;i++) {
			buff[i]=s.substring(i,i+1);
		}

		if(buff[0].equals(buff[1])&&!buff[1].equals(buff[2])&&buff[2].equals(buff[3])) {
			System.out.println("Yes");
		}else if(buff[0].equals(buff[3])&&buff[1].equals(buff[2])&&!buff[0].equals(buff[1])){
			System.out.println("Yes");
		}else if(!buff[0].equals(buff[1])&&!buff[2].equals(buff[3])&&buff[0].equals(buff[2])&&buff[1].equals(buff[3])){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

		//System.out.println(n*n);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s=sc.next(); s sc.next() sc.next sc String[] buff= {"","","",""}; buff {"","","",""} "" "" "" "" long count=0 count 0 flag=0; flag 0 long count1=0 count1 0 count2=0; count2 0 int count3=0; count3 0 int[] array = new int[3]; array new int[3] 3 Arrays.sort(array) Arrays.sort Arrays array for(int i=0;i<4;i++) {
			buff[i]=s.substring(i,i+1);
		} int i=0; int i=0; i 0 i<4 i 4 i++ i++ i {
			buff[i]=s.substring(i,i+1);
		} {
			buff[i]=s.substring(i,i+1);
		} buff[i]=s.substring(i,i+1) buff[i] buff i s.substring(i,i+1) s.substring s i i+1 i 1 if(buff[0].equals(buff[1])&&!buff[1].equals(buff[2])&&buff[2].equals(buff[3])) {
			System.out.println("Yes");
		}else if(buff[0].equals(buff[3])&&buff[1].equals(buff[2])&&!buff[0].equals(buff[1])){
			System.out.println("Yes");
		}else if(!buff[0].equals(buff[1])&&!buff[2].equals(buff[3])&&buff[0].equals(buff[2])&&buff[1].equals(buff[3])){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		} buff[0].equals(buff[1])&&!buff[1].equals(buff[2])&&buff[2].equals(buff[3]) buff[0].equals(buff[1])&&!buff[1].equals(buff[2])&&buff[2].equals(buff[3]) buff[0].equals(buff[1]) buff[0].equals buff[0] buff 0 buff[1] buff 1 !buff[1].equals(buff[2]) buff[1].equals(buff[2]) buff[1].equals buff[1] buff 1 buff[2] buff 2 buff[2].equals(buff[3]) buff[2].equals buff[2] buff 2 buff[3] buff 3 {
			System.out.println("Yes");
		} System.out.println("Yes") System.out.println System.out System System.out "Yes" if(buff[0].equals(buff[3])&&buff[1].equals(buff[2])&&!buff[0].equals(buff[1])){
			System.out.println("Yes");
		}else if(!buff[0].equals(buff[1])&&!buff[2].equals(buff[3])&&buff[0].equals(buff[2])&&buff[1].equals(buff[3])){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		} buff[0].equals(buff[3])&&buff[1].equals(buff[2])&&!buff[0].equals(buff[1]) buff[0].equals(buff[3])&&buff[1].equals(buff[2])&&!buff[0].equals(buff[1]) buff[0].equals(buff[3]) buff[0].equals buff[0] buff 0 buff[3] buff 3 buff[1].equals(buff[2]) buff[1].equals buff[1] buff 1 buff[2] buff 2 !buff[0].equals(buff[1]) buff[0].equals(buff[1]) buff[0].equals buff[0] buff 0 buff[1] buff 1 {
			System.out.println("Yes");
		} System.out.println("Yes") System.out.println System.out System System.out "Yes" if(!buff[0].equals(buff[1])&&!buff[2].equals(buff[3])&&buff[0].equals(buff[2])&&buff[1].equals(buff[3])){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		} !buff[0].equals(buff[1])&&!buff[2].equals(buff[3])&&buff[0].equals(buff[2])&&buff[1].equals(buff[3]) buff[0].equals(buff[2]) !buff[0].equals(buff[1])&&!buff[2].equals(buff[3])&&buff[0].equals(buff[2])&&buff[1].equals(buff[3]) !buff[0].equals(buff[1]) buff[0].equals(buff[1]) buff[0].equals buff[0] buff 0 buff[1] buff 1 !buff[2].equals(buff[3]) buff[2].equals(buff[3]) buff[2].equals buff[2] buff 2 buff[3] buff 3 buff[0].equals(buff[2]) buff[0].equals buff[0] buff 0 buff[2] buff 2 buff[1].equals(buff[3]) buff[1].equals buff[1] buff 1 buff[3] buff 3 {
			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) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		//String t= sc.next();
		String[] buff= {"","","",""};
		//int n = sc.nextInt();
		//int m = sc.nextInt();
		//int k = sc.nextInt();
		long count=0,flag=0;
		long count1=0,count2=0;
		int count3=0;
		int[] array = new int[3];
		/*array[0]=n-m;
		array[1]=n*m;
		array[2]=n+m;*/
		Arrays.sort(array);

		for(int i=0;i<4;i++) {
			buff[i]=s.substring(i,i+1);
		}

		if(buff[0].equals(buff[1])&&!buff[1].equals(buff[2])&&buff[2].equals(buff[3])) {
			System.out.println("Yes");
		}else if(buff[0].equals(buff[3])&&buff[1].equals(buff[2])&&!buff[0].equals(buff[1])){
			System.out.println("Yes");
		}else if(!buff[0].equals(buff[1])&&!buff[2].equals(buff[3])&&buff[0].equals(buff[2])&&buff[1].equals(buff[3])){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

		//System.out.println(n*n);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		//String t= sc.next();
		String[] buff= {"","","",""};
		//int n = sc.nextInt();
		//int m = sc.nextInt();
		//int k = sc.nextInt();
		long count=0,flag=0;
		long count1=0,count2=0;
		int count3=0;
		int[] array = new int[3];
		/*array[0]=n-m;
		array[1]=n*m;
		array[2]=n+m;*/
		Arrays.sort(array);

		for(int i=0;i<4;i++) {
			buff[i]=s.substring(i,i+1);
		}

		if(buff[0].equals(buff[1])&&!buff[1].equals(buff[2])&&buff[2].equals(buff[3])) {
			System.out.println("Yes");
		}else if(buff[0].equals(buff[3])&&buff[1].equals(buff[2])&&!buff[0].equals(buff[1])){
			System.out.println("Yes");
		}else if(!buff[0].equals(buff[1])&&!buff[2].equals(buff[3])&&buff[0].equals(buff[2])&&buff[1].equals(buff[3])){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

		//System.out.println(n*n);
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		//String t= sc.next();
		String[] buff= {"","","",""};
		//int n = sc.nextInt();
		//int m = sc.nextInt();
		//int k = sc.nextInt();
		long count=0,flag=0;
		long count1=0,count2=0;
		int count3=0;
		int[] array = new int[3];
		/*array[0]=n-m;
		array[1]=n*m;
		array[2]=n+m;*/
		Arrays.sort(array);

		for(int i=0;i<4;i++) {
			buff[i]=s.substring(i,i+1);
		}

		if(buff[0].equals(buff[1])&&!buff[1].equals(buff[2])&&buff[2].equals(buff[3])) {
			System.out.println("Yes");
		}else if(buff[0].equals(buff[3])&&buff[1].equals(buff[2])&&!buff[0].equals(buff[1])){
			System.out.println("Yes");
		}else if(!buff[0].equals(buff[1])&&!buff[2].equals(buff[3])&&buff[0].equals(buff[2])&&buff[1].equals(buff[3])){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

		//System.out.println(n*n);
	}
}


