import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		HashMap<Character, Integer> hm = new HashMap<>();
		char ch=' ';
		for(int i = 0; i < 4; i++) {
			ch = S.charAt(i);
			if(!hm.containsKey(ch)) {
				hm.put(ch, 1);
			}
			else {
				hm.put(ch, hm.get(ch) + 1);
			}
		}
		System.out.println((hm.size() == 2 && hm.get(ch) == 2)?"Yes":"No");
	}
} import java.util.*; util.* java public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		HashMap<Character, Integer> hm = new HashMap<>();
		char ch=' ';
		for(int i = 0; i < 4; i++) {
			ch = S.charAt(i);
			if(!hm.containsKey(ch)) {
				hm.put(ch, 1);
			}
			else {
				hm.put(ch, hm.get(ch) + 1);
			}
		}
		System.out.println((hm.size() == 2 && hm.get(ch) == 2)?"Yes":"No");
	}
} Main public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		HashMap<Character, Integer> hm = new HashMap<>();
		char ch=' ';
		for(int i = 0; i < 4; i++) {
			ch = S.charAt(i);
			if(!hm.containsKey(ch)) {
				hm.put(ch, 1);
			}
			else {
				hm.put(ch, hm.get(ch) + 1);
			}
		}
		System.out.println((hm.size() == 2 && hm.get(ch) == 2)?"Yes":"No");
	} main {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		HashMap<Character, Integer> hm = new HashMap<>();
		char ch=' ';
		for(int i = 0; i < 4; i++) {
			ch = S.charAt(i);
			if(!hm.containsKey(ch)) {
				hm.put(ch, 1);
			}
			else {
				hm.put(ch, hm.get(ch) + 1);
			}
		}
		System.out.println((hm.size() == 2 && hm.get(ch) == 2)?"Yes":"No");
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc HashMap<Character, Integer> hm = new HashMap<>(); hm new HashMap<>() char ch=' '; ch ' ' for(int i = 0; i < 4; i++) {
			ch = S.charAt(i);
			if(!hm.containsKey(ch)) {
				hm.put(ch, 1);
			}
			else {
				hm.put(ch, hm.get(ch) + 1);
			}
		} int i = 0; int i = 0; i 0 i < 4 i 4 i++ i++ i {
			ch = S.charAt(i);
			if(!hm.containsKey(ch)) {
				hm.put(ch, 1);
			}
			else {
				hm.put(ch, hm.get(ch) + 1);
			}
		} {
			ch = S.charAt(i);
			if(!hm.containsKey(ch)) {
				hm.put(ch, 1);
			}
			else {
				hm.put(ch, hm.get(ch) + 1);
			}
		} ch = S.charAt(i) ch S.charAt(i) S.charAt S i if(!hm.containsKey(ch)) {
				hm.put(ch, 1);
			}
			else {
				hm.put(ch, hm.get(ch) + 1);
			} !hm.containsKey(ch) hm.containsKey(ch) hm.containsKey hm ch {
				hm.put(ch, 1);
			} hm.put(ch, 1) hm.put hm ch 1 {
				hm.put(ch, hm.get(ch) + 1);
			} hm.put(ch, hm.get(ch) + 1) hm.put hm ch hm.get(ch) + 1 hm.get(ch) hm.get hm ch 1 System.out.println((hm.size() == 2 && hm.get(ch) == 2)?"Yes":"No") System.out.println System.out System System.out (hm.size() == 2 && hm.get(ch) == 2)?"Yes":"No" (hm.size() == 2 && hm.get(ch) == 2) hm.size() == 2 hm.size() hm.size hm 2 hm.get(ch) == 2 hm.get(ch) hm.get hm ch 2 "Yes" "No" String args[] args public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		HashMap<Character, Integer> hm = new HashMap<>();
		char ch=' ';
		for(int i = 0; i < 4; i++) {
			ch = S.charAt(i);
			if(!hm.containsKey(ch)) {
				hm.put(ch, 1);
			}
			else {
				hm.put(ch, hm.get(ch) + 1);
			}
		}
		System.out.println((hm.size() == 2 && hm.get(ch) == 2)?"Yes":"No");
	}
} public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		HashMap<Character, Integer> hm = new HashMap<>();
		char ch=' ';
		for(int i = 0; i < 4; i++) {
			ch = S.charAt(i);
			if(!hm.containsKey(ch)) {
				hm.put(ch, 1);
			}
			else {
				hm.put(ch, hm.get(ch) + 1);
			}
		}
		System.out.println((hm.size() == 2 && hm.get(ch) == 2)?"Yes":"No");
	}
} Main
import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		HashMap<Character, Integer> hm = new HashMap<>();
		char ch=' ';
		for(int i = 0; i < 4; i++) {
			ch = S.charAt(i);
			if(!hm.containsKey(ch)) {
				hm.put(ch, 1);
			}
			else {
				hm.put(ch, hm.get(ch) + 1);
			}
		}
		System.out.println((hm.size() == 2 && hm.get(ch) == 2)?"Yes":"No");
	}
}