import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String input = scanner.nextLine();
		
		String trimed = input.replace(input.substring(0, 1), "");
		if(trimed.length()==2){
			if(trimed.charAt(0) == trimed.charAt(1)){
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String input = scanner.nextLine();
		
		String trimed = input.replace(input.substring(0, 1), "");
		if(trimed.length()==2){
			if(trimed.charAt(0) == trimed.charAt(1)){
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}
	}
} Main public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String input = scanner.nextLine();
		
		String trimed = input.replace(input.substring(0, 1), "");
		if(trimed.length()==2){
			if(trimed.charAt(0) == trimed.charAt(1)){
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}
	} main {
		Scanner scanner = new Scanner(System.in);
		String input = scanner.nextLine();
		
		String trimed = input.replace(input.substring(0, 1), "");
		if(trimed.length()==2){
			if(trimed.charAt(0) == trimed.charAt(1)){
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String input = scanner.nextLine(); input scanner.nextLine() scanner.nextLine scanner String trimed = input.replace(input.substring(0, 1), ""); trimed input.replace(input.substring(0, 1), "") input.replace input input.substring(0, 1) input.substring input 0 1 "" if(trimed.length()==2){
			if(trimed.charAt(0) == trimed.charAt(1)){
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		} trimed.length()==2 trimed.length() trimed.length trimed 2 {
			if(trimed.charAt(0) == trimed.charAt(1)){
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} if(trimed.charAt(0) == trimed.charAt(1)){
				System.out.println("Yes");
			} else {
				System.out.println("No");
			} trimed.charAt(0) == trimed.charAt(1) trimed.charAt(0) trimed.charAt trimed 0 trimed.charAt(1) trimed.charAt trimed 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" {
			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 scanner = new Scanner(System.in);
		String input = scanner.nextLine();
		
		String trimed = input.replace(input.substring(0, 1), "");
		if(trimed.length()==2){
			if(trimed.charAt(0) == trimed.charAt(1)){
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}
	}
} public class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String input = scanner.nextLine();
		
		String trimed = input.replace(input.substring(0, 1), "");
		if(trimed.length()==2){
			if(trimed.charAt(0) == trimed.charAt(1)){
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}
	}
} Main
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String input = scanner.nextLine();
		
		String trimed = input.replace(input.substring(0, 1), "");
		if(trimed.length()==2){
			if(trimed.charAt(0) == trimed.charAt(1)){
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}
	}
}