import java.util.Scanner;

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

        String str1 = S.substring(0, 1);
        String str2 = "";
        String str3 = "none";
        boolean hantei = false;
        for(int i = 1; i < S.length(); i++){
            if(str1.equals(S.substring(i, i+1))){
                hantei = true;
            }else{
                if(str2.equals("")){
                    str2 = S.substring(i, i+1);
                }else{
                    str3 = S.substring(i, i+1);
                }
            }
        }
        if(str2.equals(str3) && hantei){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
} 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();

        String str1 = S.substring(0, 1);
        String str2 = "";
        String str3 = "none";
        boolean hantei = false;
        for(int i = 1; i < S.length(); i++){
            if(str1.equals(S.substring(i, i+1))){
                hantei = true;
            }else{
                if(str2.equals("")){
                    str2 = S.substring(i, i+1);
                }else{
                    str3 = S.substring(i, i+1);
                }
            }
        }
        if(str2.equals(str3) && hantei){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        String str1 = S.substring(0, 1);
        String str2 = "";
        String str3 = "none";
        boolean hantei = false;
        for(int i = 1; i < S.length(); i++){
            if(str1.equals(S.substring(i, i+1))){
                hantei = true;
            }else{
                if(str2.equals("")){
                    str2 = S.substring(i, i+1);
                }else{
                    str3 = S.substring(i, i+1);
                }
            }
        }
        if(str2.equals(str3) && hantei){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    } main {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        String str1 = S.substring(0, 1);
        String str2 = "";
        String str3 = "none";
        boolean hantei = false;
        for(int i = 1; i < S.length(); i++){
            if(str1.equals(S.substring(i, i+1))){
                hantei = true;
            }else{
                if(str2.equals("")){
                    str2 = S.substring(i, i+1);
                }else{
                    str3 = S.substring(i, i+1);
                }
            }
        }
        if(str2.equals(str3) && hantei){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc String str1 = S.substring(0, 1); str1 S.substring(0, 1) S.substring S 0 1 String str2 = ""; str2 "" String str3 = "none"; str3 "none" boolean hantei = false; hantei false for(int i = 1; i < S.length(); i++){
            if(str1.equals(S.substring(i, i+1))){
                hantei = true;
            }else{
                if(str2.equals("")){
                    str2 = S.substring(i, i+1);
                }else{
                    str3 = S.substring(i, i+1);
                }
            }
        } int i = 1; int i = 1; i 1 i < S.length() i S.length() S.length S i++ i++ i {
            if(str1.equals(S.substring(i, i+1))){
                hantei = true;
            }else{
                if(str2.equals("")){
                    str2 = S.substring(i, i+1);
                }else{
                    str3 = S.substring(i, i+1);
                }
            }
        } {
            if(str1.equals(S.substring(i, i+1))){
                hantei = true;
            }else{
                if(str2.equals("")){
                    str2 = S.substring(i, i+1);
                }else{
                    str3 = S.substring(i, i+1);
                }
            }
        } if(str1.equals(S.substring(i, i+1))){
                hantei = true;
            }else{
                if(str2.equals("")){
                    str2 = S.substring(i, i+1);
                }else{
                    str3 = S.substring(i, i+1);
                }
            } str1.equals(S.substring(i, i+1)) str1.equals str1 S.substring(i, i+1) S.substring S i i+1 i 1 {
                hantei = true;
            } hantei = true hantei true {
                if(str2.equals("")){
                    str2 = S.substring(i, i+1);
                }else{
                    str3 = S.substring(i, i+1);
                }
            } if(str2.equals("")){
                    str2 = S.substring(i, i+1);
                }else{
                    str3 = S.substring(i, i+1);
                } str2.equals("") str2.equals str2 "" {
                    str2 = S.substring(i, i+1);
                } str2 = S.substring(i, i+1) str2 S.substring(i, i+1) S.substring S i i+1 i 1 {
                    str3 = S.substring(i, i+1);
                } str3 = S.substring(i, i+1) str3 S.substring(i, i+1) S.substring S i i+1 i 1 if(str2.equals(str3) && hantei){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        } str2.equals(str3) && hantei str2.equals(str3) str2.equals str2 str3 hantei {
            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);
        String S = sc.next();

        String str1 = S.substring(0, 1);
        String str2 = "";
        String str3 = "none";
        boolean hantei = false;
        for(int i = 1; i < S.length(); i++){
            if(str1.equals(S.substring(i, i+1))){
                hantei = true;
            }else{
                if(str2.equals("")){
                    str2 = S.substring(i, i+1);
                }else{
                    str3 = S.substring(i, i+1);
                }
            }
        }
        if(str2.equals(str3) && hantei){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        String str1 = S.substring(0, 1);
        String str2 = "";
        String str3 = "none";
        boolean hantei = false;
        for(int i = 1; i < S.length(); i++){
            if(str1.equals(S.substring(i, i+1))){
                hantei = true;
            }else{
                if(str2.equals("")){
                    str2 = S.substring(i, i+1);
                }else{
                    str3 = S.substring(i, i+1);
                }
            }
        }
        if(str2.equals(str3) && hantei){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
} Main
import java.util.Scanner;

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

        String str1 = S.substring(0, 1);
        String str2 = "";
        String str3 = "none";
        boolean hantei = false;
        for(int i = 1; i < S.length(); i++){
            if(str1.equals(S.substring(i, i+1))){
                hantei = true;
            }else{
                if(str2.equals("")){
                    str2 = S.substring(i, i+1);
                }else{
                    str3 = S.substring(i, i+1);
                }
            }
        }
        if(str2.equals(str3) && hantei){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}
