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