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);
    }
}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz