import java.util.*;


class Main{
    public static void main(String argv[]) {
        Scanner sc = new Scanner(System.in);
        String[] str = sc.nextLine().split("");
        HashMap<String, Integer> a = new HashMap<>();
        for(String t : str){
            if(a.containsKey(t)){
                a.put(t, a.get(t)+1);
            }
            else{
                a.put(t, 1);
            }
        }

        String result = "Yes";
        if(a.size()!=2){
            result="No";
        }
        else if(a.get(str[0]) != 2){
            result = "No";
        }
        System.out.println(result);
    }
} import java.util.*; util.* java class Main{
    public static void main(String argv[]) {
        Scanner sc = new Scanner(System.in);
        String[] str = sc.nextLine().split("");
        HashMap<String, Integer> a = new HashMap<>();
        for(String t : str){
            if(a.containsKey(t)){
                a.put(t, a.get(t)+1);
            }
            else{
                a.put(t, 1);
            }
        }

        String result = "Yes";
        if(a.size()!=2){
            result="No";
        }
        else if(a.get(str[0]) != 2){
            result = "No";
        }
        System.out.println(result);
    }
} Main public static void main(String argv[]) {
        Scanner sc = new Scanner(System.in);
        String[] str = sc.nextLine().split("");
        HashMap<String, Integer> a = new HashMap<>();
        for(String t : str){
            if(a.containsKey(t)){
                a.put(t, a.get(t)+1);
            }
            else{
                a.put(t, 1);
            }
        }

        String result = "Yes";
        if(a.size()!=2){
            result="No";
        }
        else if(a.get(str[0]) != 2){
            result = "No";
        }
        System.out.println(result);
    } main {
        Scanner sc = new Scanner(System.in);
        String[] str = sc.nextLine().split("");
        HashMap<String, Integer> a = new HashMap<>();
        for(String t : str){
            if(a.containsKey(t)){
                a.put(t, a.get(t)+1);
            }
            else{
                a.put(t, 1);
            }
        }

        String result = "Yes";
        if(a.size()!=2){
            result="No";
        }
        else if(a.get(str[0]) != 2){
            result = "No";
        }
        System.out.println(result);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] str = sc.nextLine().split(""); str sc.nextLine().split("") sc.nextLine().split sc.nextLine() sc.nextLine sc "" HashMap<String, Integer> a = new HashMap<>(); a new HashMap<>() for(String t : str){
            if(a.containsKey(t)){
                a.put(t, a.get(t)+1);
            }
            else{
                a.put(t, 1);
            }
        } String t str {
            if(a.containsKey(t)){
                a.put(t, a.get(t)+1);
            }
            else{
                a.put(t, 1);
            }
        } {
            if(a.containsKey(t)){
                a.put(t, a.get(t)+1);
            }
            else{
                a.put(t, 1);
            }
        } if(a.containsKey(t)){
                a.put(t, a.get(t)+1);
            }
            else{
                a.put(t, 1);
            } a.containsKey(t) a.containsKey a t {
                a.put(t, a.get(t)+1);
            } a.put(t, a.get(t)+1) a.put a t a.get(t)+1 a.get(t) a.get a t 1 {
                a.put(t, 1);
            } a.put(t, 1) a.put a t 1 String result = "Yes"; result "Yes" if(a.size()!=2){
            result="No";
        }
        else if(a.get(str[0]) != 2){
            result = "No";
        } a.size()!=2 a.size() a.size a 2 {
            result="No";
        } result="No" result "No" if(a.get(str[0]) != 2){
            result = "No";
        } a.get(str[0]) != 2 a.get(str[0]) a.get a str[0] str 0 2 {
            result = "No";
        } result = "No" result "No" System.out.println(result) System.out.println System.out System System.out result String argv[] argv
import java.util.*;


class Main{
    public static void main(String argv[]) {
        Scanner sc = new Scanner(System.in);
        String[] str = sc.nextLine().split("");
        HashMap<String, Integer> a = new HashMap<>();
        for(String t : str){
            if(a.containsKey(t)){
                a.put(t, a.get(t)+1);
            }
            else{
                a.put(t, 1);
            }
        }

        String result = "Yes";
        if(a.size()!=2){
            result="No";
        }
        else if(a.get(str[0]) != 2){
            result = "No";
        }
        System.out.println(result);
    }
}