import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Set<Character> m = new HashSet<>();
        boolean ok = false;
        for (int i = 0; i < s.length(); i++) {
            m.add(s.charAt(i));
        }
        if (m.size() == 2) {
            int counter = 0;
            char c = s.charAt(0);
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == c) {
                    counter++;
                }
            }
            if (counter == 2) {
                ok = true;
            }
        }
        if (ok) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Set<Character> m = new HashSet<>();
        boolean ok = false;
        for (int i = 0; i < s.length(); i++) {
            m.add(s.charAt(i));
        }
        if (m.size() == 2) {
            int counter = 0;
            char c = s.charAt(0);
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == c) {
                    counter++;
                }
            }
            if (counter == 2) {
                ok = true;
            }
        }
        if (ok) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Set<Character> m = new HashSet<>();
        boolean ok = false;
        for (int i = 0; i < s.length(); i++) {
            m.add(s.charAt(i));
        }
        if (m.size() == 2) {
            int counter = 0;
            char c = s.charAt(0);
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == c) {
                    counter++;
                }
            }
            if (counter == 2) {
                ok = true;
            }
        }
        if (ok) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Set<Character> m = new HashSet<>();
        boolean ok = false;
        for (int i = 0; i < s.length(); i++) {
            m.add(s.charAt(i));
        }
        if (m.size() == 2) {
            int counter = 0;
            char c = s.charAt(0);
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == c) {
                    counter++;
                }
            }
            if (counter == 2) {
                ok = true;
            }
        }
        if (ok) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc Set<Character> m = new HashSet<>(); m new HashSet<>() boolean ok = false; ok false for (int i = 0; i < s.length(); i++) {
            m.add(s.charAt(i));
        } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
            m.add(s.charAt(i));
        } {
            m.add(s.charAt(i));
        } m.add(s.charAt(i)) m.add m s.charAt(i) s.charAt s i if (m.size() == 2) {
            int counter = 0;
            char c = s.charAt(0);
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == c) {
                    counter++;
                }
            }
            if (counter == 2) {
                ok = true;
            }
        } m.size() == 2 m.size() m.size m 2 {
            int counter = 0;
            char c = s.charAt(0);
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == c) {
                    counter++;
                }
            }
            if (counter == 2) {
                ok = true;
            }
        } int counter = 0; counter 0 char c = s.charAt(0); c s.charAt(0) s.charAt s 0 for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == c) {
                    counter++;
                }
            } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
                if (s.charAt(i) == c) {
                    counter++;
                }
            } {
                if (s.charAt(i) == c) {
                    counter++;
                }
            } if (s.charAt(i) == c) {
                    counter++;
                } s.charAt(i) == c s.charAt(i) s.charAt s i c {
                    counter++;
                } counter++ counter if (counter == 2) {
                ok = true;
            } counter == 2 counter 2 {
                ok = true;
            } ok = true ok true if (ok) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        } ok {
            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" sc.close() sc.close sc String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Set<Character> m = new HashSet<>();
        boolean ok = false;
        for (int i = 0; i < s.length(); i++) {
            m.add(s.charAt(i));
        }
        if (m.size() == 2) {
            int counter = 0;
            char c = s.charAt(0);
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == c) {
                    counter++;
                }
            }
            if (counter == 2) {
                ok = true;
            }
        }
        if (ok) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Set<Character> m = new HashSet<>();
        boolean ok = false;
        for (int i = 0; i < s.length(); i++) {
            m.add(s.charAt(i));
        }
        if (m.size() == 2) {
            int counter = 0;
            char c = s.charAt(0);
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == c) {
                    counter++;
                }
            }
            if (counter == 2) {
                ok = true;
            }
        }
        if (ok) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Set<Character> m = new HashSet<>();
        boolean ok = false;
        for (int i = 0; i < s.length(); i++) {
            m.add(s.charAt(i));
        }
        if (m.size() == 2) {
            int counter = 0;
            char c = s.charAt(0);
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == c) {
                    counter++;
                }
            }
            if (counter == 2) {
                ok = true;
            }
        }
        if (ok) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}