import java.util.*;

public class Main {

    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();

    	Map<Character, Integer> map = new HashMap<>();
    	for (int i = 0; i < 4; i++) {
    		char c = s.charAt(i);
    		if (map.containsKey(c)) {
    			int n = map.get(c);
    			n++;
    			map.put(c, n);
    		} else {
    			map.put(c, 1);
    		}
    	}
    	char c = s.charAt(0);
    	if (map.size() == 2 && map.get(c) == 2) {
    		System.out.println("Yes");
    	} else {
    		System.out.println("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();

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

    	Map<Character, Integer> map = new HashMap<>();
    	for (int i = 0; i < 4; i++) {
    		char c = s.charAt(i);
    		if (map.containsKey(c)) {
    			int n = map.get(c);
    			n++;
    			map.put(c, n);
    		} else {
    			map.put(c, 1);
    		}
    	}
    	char c = s.charAt(0);
    	if (map.size() == 2 && map.get(c) == 2) {
    		System.out.println("Yes");
    	} else {
    		System.out.println("No");
    	}
   	} main {
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();

    	Map<Character, Integer> map = new HashMap<>();
    	for (int i = 0; i < 4; i++) {
    		char c = s.charAt(i);
    		if (map.containsKey(c)) {
    			int n = map.get(c);
    			n++;
    			map.put(c, n);
    		} else {
    			map.put(c, 1);
    		}
    	}
    	char c = s.charAt(0);
    	if (map.size() == 2 && map.get(c) == 2) {
    		System.out.println("Yes");
    	} else {
    		System.out.println("No");
    	}
   	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc Map<Character, Integer> map = new HashMap<>(); map new HashMap<>() for (int i = 0; i < 4; i++) {
    		char c = s.charAt(i);
    		if (map.containsKey(c)) {
    			int n = map.get(c);
    			n++;
    			map.put(c, n);
    		} else {
    			map.put(c, 1);
    		}
    	} int i = 0; int i = 0; i 0 i < 4 i 4 i++ i++ i {
    		char c = s.charAt(i);
    		if (map.containsKey(c)) {
    			int n = map.get(c);
    			n++;
    			map.put(c, n);
    		} else {
    			map.put(c, 1);
    		}
    	} {
    		char c = s.charAt(i);
    		if (map.containsKey(c)) {
    			int n = map.get(c);
    			n++;
    			map.put(c, n);
    		} else {
    			map.put(c, 1);
    		}
    	} char c = s.charAt(i); c s.charAt(i) s.charAt s i if (map.containsKey(c)) {
    			int n = map.get(c);
    			n++;
    			map.put(c, n);
    		} else {
    			map.put(c, 1);
    		} map.containsKey(c) map.containsKey map c {
    			int n = map.get(c);
    			n++;
    			map.put(c, n);
    		} int n = map.get(c); n map.get(c) map.get map c n++ n map.put(c, n) map.put map c n {
    			map.put(c, 1);
    		} map.put(c, 1) map.put map c 1 char c = s.charAt(0); c s.charAt(0) s.charAt s 0 if (map.size() == 2 && map.get(c) == 2) {
    		System.out.println("Yes");
    	} else {
    		System.out.println("No");
    	} map.size() == 2 && map.get(c) == 2 map.size() == 2 map.size() map.size map 2 map.get(c) == 2 map.get(c) map.get map c 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 public class Main {

    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();

    	Map<Character, Integer> map = new HashMap<>();
    	for (int i = 0; i < 4; i++) {
    		char c = s.charAt(i);
    		if (map.containsKey(c)) {
    			int n = map.get(c);
    			n++;
    			map.put(c, n);
    		} else {
    			map.put(c, 1);
    		}
    	}
    	char c = s.charAt(0);
    	if (map.size() == 2 && map.get(c) == 2) {
    		System.out.println("Yes");
    	} else {
    		System.out.println("No");
    	}
   	}
} public class Main {

    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();

    	Map<Character, Integer> map = new HashMap<>();
    	for (int i = 0; i < 4; i++) {
    		char c = s.charAt(i);
    		if (map.containsKey(c)) {
    			int n = map.get(c);
    			n++;
    			map.put(c, n);
    		} else {
    			map.put(c, 1);
    		}
    	}
    	char c = s.charAt(0);
    	if (map.size() == 2 && map.get(c) == 2) {
    		System.out.println("Yes");
    	} else {
    		System.out.println("No");
    	}
   	}
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();

    	Map<Character, Integer> map = new HashMap<>();
    	for (int i = 0; i < 4; i++) {
    		char c = s.charAt(i);
    		if (map.containsKey(c)) {
    			int n = map.get(c);
    			n++;
    			map.put(c, n);
    		} else {
    			map.put(c, 1);
    		}
    	}
    	char c = s.charAt(0);
    	if (map.size() == 2 && map.get(c) == 2) {
    		System.out.println("Yes");
    	} else {
    		System.out.println("No");
    	}
   	}
}
