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);
        char[] s = sc.next().toCharArray();
        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < s.length; i++) {
            if(!map.containsKey(s[i])) {
                map.put(s[i], 1);
            }
            else {
                map.put(s[i], map.get(s[i]) + 1);
            }
        }
        if(map.size() == 2 && map.get(s[0]) == 2) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
} 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);
        char[] s = sc.next().toCharArray();
        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < s.length; i++) {
            if(!map.containsKey(s[i])) {
                map.put(s[i], 1);
            }
            else {
                map.put(s[i], map.get(s[i]) + 1);
            }
        }
        if(map.size() == 2 && map.get(s[0]) == 2) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < s.length; i++) {
            if(!map.containsKey(s[i])) {
                map.put(s[i], 1);
            }
            else {
                map.put(s[i], map.get(s[i]) + 1);
            }
        }
        if(map.size() == 2 && map.get(s[0]) == 2) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    } main {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < s.length; i++) {
            if(!map.containsKey(s[i])) {
                map.put(s[i], 1);
            }
            else {
                map.put(s[i], map.get(s[i]) + 1);
            }
        }
        if(map.size() == 2 && map.get(s[0]) == 2) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char[] s = sc.next().toCharArray(); s sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Map<Character, Integer> map = new HashMap<>(); map new HashMap<>() for (int i = 0; i < s.length; i++) {
            if(!map.containsKey(s[i])) {
                map.put(s[i], 1);
            }
            else {
                map.put(s[i], map.get(s[i]) + 1);
            }
        } int i = 0; int i = 0; i 0 i < s.length i s.length s s.length i++ i++ i {
            if(!map.containsKey(s[i])) {
                map.put(s[i], 1);
            }
            else {
                map.put(s[i], map.get(s[i]) + 1);
            }
        } {
            if(!map.containsKey(s[i])) {
                map.put(s[i], 1);
            }
            else {
                map.put(s[i], map.get(s[i]) + 1);
            }
        } if(!map.containsKey(s[i])) {
                map.put(s[i], 1);
            }
            else {
                map.put(s[i], map.get(s[i]) + 1);
            } !map.containsKey(s[i]) map.containsKey(s[i]) map.containsKey map s[i] s i {
                map.put(s[i], 1);
            } map.put(s[i], 1) map.put map s[i] s i 1 {
                map.put(s[i], map.get(s[i]) + 1);
            } map.put(s[i], map.get(s[i]) + 1) map.put map s[i] s i map.get(s[i]) + 1 map.get(s[i]) map.get map s[i] s i 1 if(map.size() == 2 && map.get(s[0]) == 2) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        } map.size() == 2 && map.get(s[0]) == 2 map.size() == 2 map.size() map.size map 2 map.get(s[0]) == 2 map.get(s[0]) map.get map s[0] s 0 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);
        char[] s = sc.next().toCharArray();
        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < s.length; i++) {
            if(!map.containsKey(s[i])) {
                map.put(s[i], 1);
            }
            else {
                map.put(s[i], map.get(s[i]) + 1);
            }
        }
        if(map.size() == 2 && map.get(s[0]) == 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);
        char[] s = sc.next().toCharArray();
        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < s.length; i++) {
            if(!map.containsKey(s[i])) {
                map.put(s[i], 1);
            }
            else {
                map.put(s[i], map.get(s[i]) + 1);
            }
        }
        if(map.size() == 2 && map.get(s[0]) == 2) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
} 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);
        char[] s = sc.next().toCharArray();
        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < s.length; i++) {
            if(!map.containsKey(s[i])) {
                map.put(s[i], 1);
            }
            else {
                map.put(s[i], map.get(s[i]) + 1);
            }
        }
        if(map.size() == 2 && map.get(s[0]) == 2) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}