import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	String S=sc.next();
	String[] S2=S.split("");
	if(S2[0].equals(S2[1])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[3])) {
		System.out.println("Yes");
	}else if(S2[0].equals(S2[2])&&!S2[0].equals(S2[1])&&S2[1].equals(S2[3])) {
		System.out.println("Yes");
	}else if(S2[0].equals(S2[3])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[1])) {
		System.out.println("Yes");
	}else {
		System.out.println("No");
	}
}
} import java.util.Scanner; Scanner java.util public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	String S=sc.next();
	String[] S2=S.split("");
	if(S2[0].equals(S2[1])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[3])) {
		System.out.println("Yes");
	}else if(S2[0].equals(S2[2])&&!S2[0].equals(S2[1])&&S2[1].equals(S2[3])) {
		System.out.println("Yes");
	}else if(S2[0].equals(S2[3])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[1])) {
		System.out.println("Yes");
	}else {
		System.out.println("No");
	}
}
} Main @SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	String S=sc.next();
	String[] S2=S.split("");
	if(S2[0].equals(S2[1])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[3])) {
		System.out.println("Yes");
	}else if(S2[0].equals(S2[2])&&!S2[0].equals(S2[1])&&S2[1].equals(S2[3])) {
		System.out.println("Yes");
	}else if(S2[0].equals(S2[3])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[1])) {
		System.out.println("Yes");
	}else {
		System.out.println("No");
	}
} main {
	Scanner sc =new Scanner(System.in);
	String S=sc.next();
	String[] S2=S.split("");
	if(S2[0].equals(S2[1])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[3])) {
		System.out.println("Yes");
	}else if(S2[0].equals(S2[2])&&!S2[0].equals(S2[1])&&S2[1].equals(S2[3])) {
		System.out.println("Yes");
	}else if(S2[0].equals(S2[3])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[1])) {
		System.out.println("Yes");
	}else {
		System.out.println("No");
	}
} Scanner sc =new Scanner(System.in); sc new Scanner(System.in) String S=sc.next(); S sc.next() sc.next sc String[] S2=S.split(""); S2 S.split("") S.split S "" if(S2[0].equals(S2[1])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[3])) {
		System.out.println("Yes");
	}else if(S2[0].equals(S2[2])&&!S2[0].equals(S2[1])&&S2[1].equals(S2[3])) {
		System.out.println("Yes");
	}else if(S2[0].equals(S2[3])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[1])) {
		System.out.println("Yes");
	}else {
		System.out.println("No");
	} S2[0].equals(S2[1])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[3]) S2[0].equals(S2[1])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[3]) S2[0].equals(S2[1]) S2[0].equals S2[0] S2 0 S2[1] S2 1 !S2[0].equals(S2[2]) S2[0].equals(S2[2]) S2[0].equals S2[0] S2 0 S2[2] S2 2 S2[2].equals(S2[3]) S2[2].equals S2[2] S2 2 S2[3] S2 3 {
		System.out.println("Yes");
	} System.out.println("Yes") System.out.println System.out System System.out "Yes" if(S2[0].equals(S2[2])&&!S2[0].equals(S2[1])&&S2[1].equals(S2[3])) {
		System.out.println("Yes");
	}else if(S2[0].equals(S2[3])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[1])) {
		System.out.println("Yes");
	}else {
		System.out.println("No");
	} S2[0].equals(S2[2])&&!S2[0].equals(S2[1])&&S2[1].equals(S2[3]) S2[0].equals(S2[2])&&!S2[0].equals(S2[1])&&S2[1].equals(S2[3]) S2[0].equals(S2[2]) S2[0].equals S2[0] S2 0 S2[2] S2 2 !S2[0].equals(S2[1]) S2[0].equals(S2[1]) S2[0].equals S2[0] S2 0 S2[1] S2 1 S2[1].equals(S2[3]) S2[1].equals S2[1] S2 1 S2[3] S2 3 {
		System.out.println("Yes");
	} System.out.println("Yes") System.out.println System.out System System.out "Yes" if(S2[0].equals(S2[3])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[1])) {
		System.out.println("Yes");
	}else {
		System.out.println("No");
	} S2[0].equals(S2[3])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[1]) S2[0].equals(S2[3])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[1]) S2[0].equals(S2[3]) S2[0].equals S2[0] S2 0 S2[3] S2 3 !S2[0].equals(S2[2]) S2[0].equals(S2[2]) S2[0].equals S2[0] S2 0 S2[2] S2 2 S2[2].equals(S2[1]) S2[2].equals S2[2] S2 2 S2[1] S2 1 {
		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 {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	String S=sc.next();
	String[] S2=S.split("");
	if(S2[0].equals(S2[1])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[3])) {
		System.out.println("Yes");
	}else if(S2[0].equals(S2[2])&&!S2[0].equals(S2[1])&&S2[1].equals(S2[3])) {
		System.out.println("Yes");
	}else if(S2[0].equals(S2[3])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[1])) {
		System.out.println("Yes");
	}else {
		System.out.println("No");
	}
}
} public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	String S=sc.next();
	String[] S2=S.split("");
	if(S2[0].equals(S2[1])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[3])) {
		System.out.println("Yes");
	}else if(S2[0].equals(S2[2])&&!S2[0].equals(S2[1])&&S2[1].equals(S2[3])) {
		System.out.println("Yes");
	}else if(S2[0].equals(S2[3])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[1])) {
		System.out.println("Yes");
	}else {
		System.out.println("No");
	}
}
} Main
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	String S=sc.next();
	String[] S2=S.split("");
	if(S2[0].equals(S2[1])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[3])) {
		System.out.println("Yes");
	}else if(S2[0].equals(S2[2])&&!S2[0].equals(S2[1])&&S2[1].equals(S2[3])) {
		System.out.println("Yes");
	}else if(S2[0].equals(S2[3])&&!S2[0].equals(S2[2])&&S2[2].equals(S2[1])) {
		System.out.println("Yes");
	}else {
		System.out.println("No");
	}
}
}