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 (char c : s.toCharArray()) {
            int count = map.getOrDefault(c, 0);
            map.put(c, ++count);
        }
        Set<Character> cs = map.keySet();
        if (cs.size() != 2) {
            System.out.println("No");
            return;
        }
        for (int i : map.values()) {
            if (i != 2) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
} 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 (char c : s.toCharArray()) {
            int count = map.getOrDefault(c, 0);
            map.put(c, ++count);
        }
        Set<Character> cs = map.keySet();
        if (cs.size() != 2) {
            System.out.println("No");
            return;
        }
        for (int i : map.values()) {
            if (i != 2) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
} Main public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Map<Character, Integer> map = new HashMap<>();
        for (char c : s.toCharArray()) {
            int count = map.getOrDefault(c, 0);
            map.put(c, ++count);
        }
        Set<Character> cs = map.keySet();
        if (cs.size() != 2) {
            System.out.println("No");
            return;
        }
        for (int i : map.values()) {
            if (i != 2) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Map<Character, Integer> map = new HashMap<>();
        for (char c : s.toCharArray()) {
            int count = map.getOrDefault(c, 0);
            map.put(c, ++count);
        }
        Set<Character> cs = map.keySet();
        if (cs.size() != 2) {
            System.out.println("No");
            return;
        }
        for (int i : map.values()) {
            if (i != 2) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    } 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 (char c : s.toCharArray()) {
            int count = map.getOrDefault(c, 0);
            map.put(c, ++count);
        } char c s.toCharArray() s.toCharArray s {
            int count = map.getOrDefault(c, 0);
            map.put(c, ++count);
        } {
            int count = map.getOrDefault(c, 0);
            map.put(c, ++count);
        } int count = map.getOrDefault(c, 0); count map.getOrDefault(c, 0) map.getOrDefault map c 0 map.put(c, ++count) map.put map c ++count count Set<Character> cs = map.keySet(); cs map.keySet() map.keySet map if (cs.size() != 2) {
            System.out.println("No");
            return;
        } cs.size() != 2 cs.size() cs.size cs 2 {
            System.out.println("No");
            return;
        } System.out.println("No") System.out.println System.out System System.out "No" return; for (int i : map.values()) {
            if (i != 2) {
                System.out.println("No");
                return;
            }
        } int i map.values() map.values map {
            if (i != 2) {
                System.out.println("No");
                return;
            }
        } {
            if (i != 2) {
                System.out.println("No");
                return;
            }
        } if (i != 2) {
                System.out.println("No");
                return;
            } i != 2 i 2 {
                System.out.println("No");
                return;
            } System.out.println("No") System.out.println System.out System System.out "No" return; System.out.println("Yes") System.out.println System.out System System.out "Yes" 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 (char c : s.toCharArray()) {
            int count = map.getOrDefault(c, 0);
            map.put(c, ++count);
        }
        Set<Character> cs = map.keySet();
        if (cs.size() != 2) {
            System.out.println("No");
            return;
        }
        for (int i : map.values()) {
            if (i != 2) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
} 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 (char c : s.toCharArray()) {
            int count = map.getOrDefault(c, 0);
            map.put(c, ++count);
        }
        Set<Character> cs = map.keySet();
        if (cs.size() != 2) {
            System.out.println("No");
            return;
        }
        for (int i : map.values()) {
            if (i != 2) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
} 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 (char c : s.toCharArray()) {
            int count = map.getOrDefault(c, 0);
            map.put(c, ++count);
        }
        Set<Character> cs = map.keySet();
        if (cs.size() != 2) {
            System.out.println("No");
            return;
        }
        for (int i : map.values()) {
            if (i != 2) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
}