import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		String s = sc.next();
		char[] c = s.toCharArray();

		Arrays.sort(c);
		if(c[0]==c[1]&&c[2]==c[3]&&c[1]!=c[2]) out.println("Yes");
		else out.println("No");

		out.flush();
	}
} import java.io.PrintWriter; PrintWriter java.io import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		String s = sc.next();
		char[] c = s.toCharArray();

		Arrays.sort(c);
		if(c[0]==c[1]&&c[2]==c[3]&&c[1]!=c[2]) out.println("Yes");
		else out.println("No");

		out.flush();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		String s = sc.next();
		char[] c = s.toCharArray();

		Arrays.sort(c);
		if(c[0]==c[1]&&c[2]==c[3]&&c[1]!=c[2]) out.println("Yes");
		else out.println("No");

		out.flush();
	} main {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		String s = sc.next();
		char[] c = s.toCharArray();

		Arrays.sort(c);
		if(c[0]==c[1]&&c[2]==c[3]&&c[1]!=c[2]) out.println("Yes");
		else out.println("No");

		out.flush();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) String s = sc.next(); s sc.next() sc.next sc char[] c = s.toCharArray(); c s.toCharArray() s.toCharArray s Arrays.sort(c) Arrays.sort Arrays c if(c[0]==c[1]&&c[2]==c[3]&&c[1]!=c[2]) out.println("Yes");
		else out.println("No"); c[0]==c[1]&&c[2]==c[3]&&c[1]!=c[2] c[0]==c[1]&&c[2]==c[3]&&c[1]!=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[1]!=c[2] c[1] c 1 c[2] c 2 out.println("Yes") out.println out "Yes" out.println("No") out.println out "No" out.flush() out.flush out String[] args args
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		String s = sc.next();
		char[] c = s.toCharArray();

		Arrays.sort(c);
		if(c[0]==c[1]&&c[2]==c[3]&&c[1]!=c[2]) out.println("Yes");
		else out.println("No");

		out.flush();
	}
}
