import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        String n = s.nextLine();
        String s1 = String.valueOf(n.charAt(0));
        int i1=0;
        int i2=0;
        String s2="";
        for(int i=0;i<n.length();i++){
            if(String.valueOf(n.charAt(i)).equals(s1)){
                i1++;
            }else{
                if (s2.equals("") || String.valueOf(n.charAt(i)).equals(s2)) {
                    s2=String.valueOf(n.charAt(i));
                    i2++;
                }
            }
        }
        System.out.println(i1==2&&i2==2?"Yes":"No");
    }
}
/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