import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char a = str.charAt(0);
		char b = str.charAt(1);
		char c = str.charAt(2);
		char d = str.charAt(3);
		if (a == b && c == d && a != c || a == c && b == d && a != b || a == d && b == c && a != b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char a = str.charAt(0);
		char b = str.charAt(1);
		char c = str.charAt(2);
		char d = str.charAt(3);
		if (a == b && c == d && a != c || a == c && b == d && a != b || a == d && b == c && a != b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char a = str.charAt(0);
		char b = str.charAt(1);
		char c = str.charAt(2);
		char d = str.charAt(3);
		if (a == b && c == d && a != c || a == c && b == d && a != b || a == d && b == c && a != b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char a = str.charAt(0);
		char b = str.charAt(1);
		char c = str.charAt(2);
		char d = str.charAt(3);
		if (a == b && c == d && a != c || a == c && b == d && a != b || a == d && b == c && a != b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.next(); str sc.next() sc.next sc char a = str.charAt(0); a str.charAt(0) str.charAt str 0 char b = str.charAt(1); b str.charAt(1) str.charAt str 1 char c = str.charAt(2); c str.charAt(2) str.charAt str 2 char d = str.charAt(3); d str.charAt(3) str.charAt str 3 if (a == b && c == d && a != c || a == c && b == d && a != b || a == d && b == c && a != b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		} a == b && c == d && a != c || a == c && b == d && a != b || a == d && b == c && a != b a == b && c == d && a != c || a == c && b == d && a != b || a == d && b == c && a != b a == b && c == d && a != c a == b && c == d && a != c a == b a b c == d c d a != c a c a == c && b == d && a != b a == c && b == d && a != b a == c a c b == d b d a != b a b a == d && b == c && a != b a == d && b == c && a != b a == d a d b == c b c a != b a b {
			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" sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char a = str.charAt(0);
		char b = str.charAt(1);
		char c = str.charAt(2);
		char d = str.charAt(3);
		if (a == b && c == d && a != c || a == c && b == d && a != b || a == d && b == c && a != b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char a = str.charAt(0);
		char b = str.charAt(1);
		char c = str.charAt(2);
		char d = str.charAt(3);
		if (a == b && c == d && a != c || a == c && b == d && a != b || a == d && b == c && a != b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char a = str.charAt(0);
		char b = str.charAt(1);
		char c = str.charAt(2);
		char d = str.charAt(3);
		if (a == b && c == d && a != c || a == c && b == d && a != b || a == d && b == c && a != b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}
}