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<String, Integer> sMap = new HashMap<String, Integer>();
        for (int i = 0; i < S.length(); i++) {
            String s = S.substring(i, i + 1);
            Integer sCount = 1;
            if (sMap.containsKey(s)) {
                sCount = sMap.get(s) + 1;
            }
            sMap.put(s, sCount);
        }

        if (sMap.size() != 2) {
            System.out.println("No");
            return;
        }

        for (String s : sMap.keySet()) {
            if (sMap.get(s) == 2) {
                System.out.println("Yes");
                return;
            } else {
                System.out.println("No");
                return;
            }
        }

    }
} 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<String, Integer> sMap = new HashMap<String, Integer>();
        for (int i = 0; i < S.length(); i++) {
            String s = S.substring(i, i + 1);
            Integer sCount = 1;
            if (sMap.containsKey(s)) {
                sCount = sMap.get(s) + 1;
            }
            sMap.put(s, sCount);
        }

        if (sMap.size() != 2) {
            System.out.println("No");
            return;
        }

        for (String s : sMap.keySet()) {
            if (sMap.get(s) == 2) {
                System.out.println("Yes");
                return;
            } else {
                System.out.println("No");
                return;
            }
        }

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

        Map<String, Integer> sMap = new HashMap<String, Integer>();
        for (int i = 0; i < S.length(); i++) {
            String s = S.substring(i, i + 1);
            Integer sCount = 1;
            if (sMap.containsKey(s)) {
                sCount = sMap.get(s) + 1;
            }
            sMap.put(s, sCount);
        }

        if (sMap.size() != 2) {
            System.out.println("No");
            return;
        }

        for (String s : sMap.keySet()) {
            if (sMap.get(s) == 2) {
                System.out.println("Yes");
                return;
            } else {
                System.out.println("No");
                return;
            }
        }

    } main {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        sc.close();

        Map<String, Integer> sMap = new HashMap<String, Integer>();
        for (int i = 0; i < S.length(); i++) {
            String s = S.substring(i, i + 1);
            Integer sCount = 1;
            if (sMap.containsKey(s)) {
                sCount = sMap.get(s) + 1;
            }
            sMap.put(s, sCount);
        }

        if (sMap.size() != 2) {
            System.out.println("No");
            return;
        }

        for (String s : sMap.keySet()) {
            if (sMap.get(s) == 2) {
                System.out.println("Yes");
                return;
            } else {
                System.out.println("No");
                return;
            }
        }

    } 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<String, Integer> sMap = new HashMap<String, Integer>(); sMap new HashMap<String, Integer>() for (int i = 0; i < S.length(); i++) {
            String s = S.substring(i, i + 1);
            Integer sCount = 1;
            if (sMap.containsKey(s)) {
                sCount = sMap.get(s) + 1;
            }
            sMap.put(s, sCount);
        } int i = 0; int i = 0; i 0 i < S.length() i S.length() S.length S i++ i++ i {
            String s = S.substring(i, i + 1);
            Integer sCount = 1;
            if (sMap.containsKey(s)) {
                sCount = sMap.get(s) + 1;
            }
            sMap.put(s, sCount);
        } {
            String s = S.substring(i, i + 1);
            Integer sCount = 1;
            if (sMap.containsKey(s)) {
                sCount = sMap.get(s) + 1;
            }
            sMap.put(s, sCount);
        } String s = S.substring(i, i + 1); s S.substring(i, i + 1) S.substring S i i + 1 i 1 Integer sCount = 1; sCount 1 if (sMap.containsKey(s)) {
                sCount = sMap.get(s) + 1;
            } sMap.containsKey(s) sMap.containsKey sMap s {
                sCount = sMap.get(s) + 1;
            } sCount = sMap.get(s) + 1 sCount sMap.get(s) + 1 sMap.get(s) sMap.get sMap s 1 sMap.put(s, sCount) sMap.put sMap s sCount if (sMap.size() != 2) {
            System.out.println("No");
            return;
        } sMap.size() != 2 sMap.size() sMap.size sMap 2 {
            System.out.println("No");
            return;
        } System.out.println("No") System.out.println System.out System System.out "No" return; for (String s : sMap.keySet()) {
            if (sMap.get(s) == 2) {
                System.out.println("Yes");
                return;
            } else {
                System.out.println("No");
                return;
            }
        } String s sMap.keySet() sMap.keySet sMap {
            if (sMap.get(s) == 2) {
                System.out.println("Yes");
                return;
            } else {
                System.out.println("No");
                return;
            }
        } {
            if (sMap.get(s) == 2) {
                System.out.println("Yes");
                return;
            } else {
                System.out.println("No");
                return;
            }
        } if (sMap.get(s) == 2) {
                System.out.println("Yes");
                return;
            } else {
                System.out.println("No");
                return;
            } sMap.get(s) == 2 sMap.get(s) sMap.get sMap s 2 {
                System.out.println("Yes");
                return;
            } System.out.println("Yes") System.out.println System.out System System.out "Yes" return; {
                System.out.println("No");
                return;
            } System.out.println("No") System.out.println System.out System System.out "No" return; 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<String, Integer> sMap = new HashMap<String, Integer>();
        for (int i = 0; i < S.length(); i++) {
            String s = S.substring(i, i + 1);
            Integer sCount = 1;
            if (sMap.containsKey(s)) {
                sCount = sMap.get(s) + 1;
            }
            sMap.put(s, sCount);
        }

        if (sMap.size() != 2) {
            System.out.println("No");
            return;
        }

        for (String s : sMap.keySet()) {
            if (sMap.get(s) == 2) {
                System.out.println("Yes");
                return;
            } else {
                System.out.println("No");
                return;
            }
        }

    }
} public class Main {

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

        Map<String, Integer> sMap = new HashMap<String, Integer>();
        for (int i = 0; i < S.length(); i++) {
            String s = S.substring(i, i + 1);
            Integer sCount = 1;
            if (sMap.containsKey(s)) {
                sCount = sMap.get(s) + 1;
            }
            sMap.put(s, sCount);
        }

        if (sMap.size() != 2) {
            System.out.println("No");
            return;
        }

        for (String s : sMap.keySet()) {
            if (sMap.get(s) == 2) {
                System.out.println("Yes");
                return;
            } else {
                System.out.println("No");
                return;
            }
        }

    }
} 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<String, Integer> sMap = new HashMap<String, Integer>();
        for (int i = 0; i < S.length(); i++) {
            String s = S.substring(i, i + 1);
            Integer sCount = 1;
            if (sMap.containsKey(s)) {
                sCount = sMap.get(s) + 1;
            }
            sMap.put(s, sCount);
        }

        if (sMap.size() != 2) {
            System.out.println("No");
            return;
        }

        for (String s : sMap.keySet()) {
            if (sMap.get(s) == 2) {
                System.out.println("Yes");
                return;
            } else {
                System.out.println("No");
                return;
            }
        }

    }
}