import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            if (map.containsKey(s.charAt(i))) {
                map.put(s.charAt(i), map.get(s.charAt(i)) + 1);
            } else {
                map.put(s.charAt(i), 1);
            }
        }

        String ans = "Yes";
        if (map.keySet().size() != 2) {
            ans = "No";
        }
        for (Character ch : map.keySet()) {
            if (map.get(ch) != 2) {
                ans = "No";
            }
        }
        System.out.println(ans);
    }

} import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util public class Main {

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

        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            if (map.containsKey(s.charAt(i))) {
                map.put(s.charAt(i), map.get(s.charAt(i)) + 1);
            } else {
                map.put(s.charAt(i), 1);
            }
        }

        String ans = "Yes";
        if (map.keySet().size() != 2) {
            ans = "No";
        }
        for (Character ch : map.keySet()) {
            if (map.get(ch) != 2) {
                ans = "No";
            }
        }
        System.out.println(ans);
    }

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

        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            if (map.containsKey(s.charAt(i))) {
                map.put(s.charAt(i), map.get(s.charAt(i)) + 1);
            } else {
                map.put(s.charAt(i), 1);
            }
        }

        String ans = "Yes";
        if (map.keySet().size() != 2) {
            ans = "No";
        }
        for (Character ch : map.keySet()) {
            if (map.get(ch) != 2) {
                ans = "No";
            }
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            if (map.containsKey(s.charAt(i))) {
                map.put(s.charAt(i), map.get(s.charAt(i)) + 1);
            } else {
                map.put(s.charAt(i), 1);
            }
        }

        String ans = "Yes";
        if (map.keySet().size() != 2) {
            ans = "No";
        }
        for (Character ch : map.keySet()) {
            if (map.get(ch) != 2) {
                ans = "No";
            }
        }
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc sc.close() sc.close sc Map<Character, Integer> map = new HashMap<>(); map new HashMap<>() for (int i = 0; i < s.length(); i++) {
            if (map.containsKey(s.charAt(i))) {
                map.put(s.charAt(i), map.get(s.charAt(i)) + 1);
            } else {
                map.put(s.charAt(i), 1);
            }
        } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
            if (map.containsKey(s.charAt(i))) {
                map.put(s.charAt(i), map.get(s.charAt(i)) + 1);
            } else {
                map.put(s.charAt(i), 1);
            }
        } {
            if (map.containsKey(s.charAt(i))) {
                map.put(s.charAt(i), map.get(s.charAt(i)) + 1);
            } else {
                map.put(s.charAt(i), 1);
            }
        } if (map.containsKey(s.charAt(i))) {
                map.put(s.charAt(i), map.get(s.charAt(i)) + 1);
            } else {
                map.put(s.charAt(i), 1);
            } map.containsKey(s.charAt(i)) map.containsKey map s.charAt(i) s.charAt s i {
                map.put(s.charAt(i), map.get(s.charAt(i)) + 1);
            } map.put(s.charAt(i), map.get(s.charAt(i)) + 1) map.put map s.charAt(i) s.charAt s i map.get(s.charAt(i)) + 1 map.get(s.charAt(i)) map.get map s.charAt(i) s.charAt s i 1 {
                map.put(s.charAt(i), 1);
            } map.put(s.charAt(i), 1) map.put map s.charAt(i) s.charAt s i 1 String ans = "Yes"; ans "Yes" if (map.keySet().size() != 2) {
            ans = "No";
        } map.keySet().size() != 2 map.keySet().size() map.keySet().size map.keySet() map.keySet map 2 {
            ans = "No";
        } ans = "No" ans "No" for (Character ch : map.keySet()) {
            if (map.get(ch) != 2) {
                ans = "No";
            }
        } Character ch map.keySet() map.keySet map {
            if (map.get(ch) != 2) {
                ans = "No";
            }
        } {
            if (map.get(ch) != 2) {
                ans = "No";
            }
        } if (map.get(ch) != 2) {
                ans = "No";
            } map.get(ch) != 2 map.get(ch) map.get map ch 2 {
                ans = "No";
            } ans = "No" ans "No" System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

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

        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            if (map.containsKey(s.charAt(i))) {
                map.put(s.charAt(i), map.get(s.charAt(i)) + 1);
            } else {
                map.put(s.charAt(i), 1);
            }
        }

        String ans = "Yes";
        if (map.keySet().size() != 2) {
            ans = "No";
        }
        for (Character ch : map.keySet()) {
            if (map.get(ch) != 2) {
                ans = "No";
            }
        }
        System.out.println(ans);
    }

} public class Main {

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

        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            if (map.containsKey(s.charAt(i))) {
                map.put(s.charAt(i), map.get(s.charAt(i)) + 1);
            } else {
                map.put(s.charAt(i), 1);
            }
        }

        String ans = "Yes";
        if (map.keySet().size() != 2) {
            ans = "No";
        }
        for (Character ch : map.keySet()) {
            if (map.get(ch) != 2) {
                ans = "No";
            }
        }
        System.out.println(ans);
    }

} Main
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            if (map.containsKey(s.charAt(i))) {
                map.put(s.charAt(i), map.get(s.charAt(i)) + 1);
            } else {
                map.put(s.charAt(i), 1);
            }
        }

        String ans = "Yes";
        if (map.keySet().size() != 2) {
            ans = "No";
        }
        for (Character ch : map.keySet()) {
            if (map.get(ch) != 2) {
                ans = "No";
            }
        }
        System.out.println(ans);
    }

}
