import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		int[] charArray = readLine().chars().sorted().toArray();
		if (charArray[0] == charArray[1] && charArray[2] == charArray[3] && charArray[0] != charArray[2]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
	
	private static String readLine() throws IOException {
		return new BufferedReader(new InputStreamReader(System.in)).readLine();
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws Exception {
		int[] charArray = readLine().chars().sorted().toArray();
		if (charArray[0] == charArray[1] && charArray[2] == charArray[3] && charArray[0] != charArray[2]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
	
	private static String readLine() throws IOException {
		return new BufferedReader(new InputStreamReader(System.in)).readLine();
	}
} Main public static void main(String[] args) throws Exception {
		int[] charArray = readLine().chars().sorted().toArray();
		if (charArray[0] == charArray[1] && charArray[2] == charArray[3] && charArray[0] != charArray[2]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	} main {
		int[] charArray = readLine().chars().sorted().toArray();
		if (charArray[0] == charArray[1] && charArray[2] == charArray[3] && charArray[0] != charArray[2]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	} int[] charArray = readLine().chars().sorted().toArray(); charArray readLine().chars().sorted().toArray() readLine().chars().sorted().toArray readLine().chars().sorted() readLine().chars().sorted readLine().chars() readLine().chars readLine() readLine if (charArray[0] == charArray[1] && charArray[2] == charArray[3] && charArray[0] != charArray[2]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		} charArray[0] == charArray[1] && charArray[2] == charArray[3] && charArray[0] != charArray[2] charArray[0] == charArray[1] && charArray[2] == charArray[3] && charArray[0] != charArray[2] charArray[0] == charArray[1] charArray[0] charArray 0 charArray[1] charArray 1 charArray[2] == charArray[3] charArray[2] charArray 2 charArray[3] charArray 3 charArray[0] != charArray[2] charArray[0] charArray 0 charArray[2] charArray 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 private static String readLine() throws IOException {
		return new BufferedReader(new InputStreamReader(System.in)).readLine();
	} readLine {
		return new BufferedReader(new InputStreamReader(System.in)).readLine();
	} return new BufferedReader(new InputStreamReader(System.in)).readLine(); new BufferedReader(new InputStreamReader(System.in)).readLine() new BufferedReader(new InputStreamReader(System.in)).readLine new BufferedReader(new InputStreamReader(System.in)) public class Main {

	public static void main(String[] args) throws Exception {
		int[] charArray = readLine().chars().sorted().toArray();
		if (charArray[0] == charArray[1] && charArray[2] == charArray[3] && charArray[0] != charArray[2]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
	
	private static String readLine() throws IOException {
		return new BufferedReader(new InputStreamReader(System.in)).readLine();
	}
} public class Main {

	public static void main(String[] args) throws Exception {
		int[] charArray = readLine().chars().sorted().toArray();
		if (charArray[0] == charArray[1] && charArray[2] == charArray[3] && charArray[0] != charArray[2]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
	
	private static String readLine() throws IOException {
		return new BufferedReader(new InputStreamReader(System.in)).readLine();
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		int[] charArray = readLine().chars().sorted().toArray();
		if (charArray[0] == charArray[1] && charArray[2] == charArray[3] && charArray[0] != charArray[2]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
	
	private static String readLine() throws IOException {
		return new BufferedReader(new InputStreamReader(System.in)).readLine();
	}
}
