import java.util.*;
import static java.lang.System.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] c =sc.next().toCharArray();
		boolean flag = false;
		if ( c[0] == c[1] && c[2] == c[3] && c[0] != c[2])
			flag = true;
		if (c[0] == c[2] && c[1] == c[3] && c[0 ] != c[1])
			flag = true;
		if (c[0] == c[3] && c[1] == c[2] && c[0] != c[1])
			flag = true;
		if(flag)
			out.println("Yes");
		else
			out.println("No");
		
	}
} import java.util.*; util.* java import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] c =sc.next().toCharArray();
		boolean flag = false;
		if ( c[0] == c[1] && c[2] == c[3] && c[0] != c[2])
			flag = true;
		if (c[0] == c[2] && c[1] == c[3] && c[0 ] != c[1])
			flag = true;
		if (c[0] == c[3] && c[1] == c[2] && c[0] != c[1])
			flag = true;
		if(flag)
			out.println("Yes");
		else
			out.println("No");
		
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] c =sc.next().toCharArray();
		boolean flag = false;
		if ( c[0] == c[1] && c[2] == c[3] && c[0] != c[2])
			flag = true;
		if (c[0] == c[2] && c[1] == c[3] && c[0 ] != c[1])
			flag = true;
		if (c[0] == c[3] && c[1] == c[2] && c[0] != c[1])
			flag = true;
		if(flag)
			out.println("Yes");
		else
			out.println("No");
		
	} main {
		Scanner sc = new Scanner(System.in);
		char[] c =sc.next().toCharArray();
		boolean flag = false;
		if ( c[0] == c[1] && c[2] == c[3] && c[0] != c[2])
			flag = true;
		if (c[0] == c[2] && c[1] == c[3] && c[0 ] != c[1])
			flag = true;
		if (c[0] == c[3] && c[1] == c[2] && c[0] != c[1])
			flag = true;
		if(flag)
			out.println("Yes");
		else
			out.println("No");
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char[] c =sc.next().toCharArray(); c sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc boolean flag = false; flag false if ( c[0] == c[1] && c[2] == c[3] && c[0] != c[2])
			flag = true; c[0] == c[1] && c[2] == c[3] && c[0] != c[2] c[0] == c[1] && c[2] == c[3] && c[0] != c[2] c[0] == c[1] c[0] c 0 c[1] c 1 c[2] == c[3] c[2] c 2 c[3] c 3 c[0] != c[2] c[0] c 0 c[2] c 2 flag = true flag true if (c[0] == c[2] && c[1] == c[3] && c[0 ] != c[1])
			flag = true; c[0] == c[2] && c[1] == c[3] && c[0 ] != c[1] c[0] == c[2] && c[1] == c[3] && c[0 ] != c[1] c[0] == c[2] c[0] c 0 c[2] c 2 c[1] == c[3] c[1] c 1 c[3] c 3 c[0 ] != c[1] c[0 ] c 0 c[1] c 1 flag = true flag true if (c[0] == c[3] && c[1] == c[2] && c[0] != c[1])
			flag = true; c[0] == c[3] && c[1] == c[2] && c[0] != c[1] c[0] == c[3] && c[1] == c[2] && c[0] != c[1] c[0] == c[3] c[0] c 0 c[3] c 3 c[1] == c[2] c[1] c 1 c[2] c 2 c[0] != c[1] c[0] c 0 c[1] c 1 flag = true flag true if(flag)
			out.println("Yes");
		else
			out.println("No"); flag out.println("Yes") out.println out "Yes" out.println("No") out.println out "No" String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] c =sc.next().toCharArray();
		boolean flag = false;
		if ( c[0] == c[1] && c[2] == c[3] && c[0] != c[2])
			flag = true;
		if (c[0] == c[2] && c[1] == c[3] && c[0 ] != c[1])
			flag = true;
		if (c[0] == c[3] && c[1] == c[2] && c[0] != c[1])
			flag = true;
		if(flag)
			out.println("Yes");
		else
			out.println("No");
		
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] c =sc.next().toCharArray();
		boolean flag = false;
		if ( c[0] == c[1] && c[2] == c[3] && c[0] != c[2])
			flag = true;
		if (c[0] == c[2] && c[1] == c[3] && c[0 ] != c[1])
			flag = true;
		if (c[0] == c[3] && c[1] == c[2] && c[0] != c[1])
			flag = true;
		if(flag)
			out.println("Yes");
		else
			out.println("No");
		
	}
} Main
import java.util.*;
import static java.lang.System.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] c =sc.next().toCharArray();
		boolean flag = false;
		if ( c[0] == c[1] && c[2] == c[3] && c[0] != c[2])
			flag = true;
		if (c[0] == c[2] && c[1] == c[3] && c[0 ] != c[1])
			flag = true;
		if (c[0] == c[3] && c[1] == c[2] && c[0] != c[1])
			flag = true;
		if(flag)
			out.println("Yes");
		else
			out.println("No");
		
	}
}