import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

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

        String S = sc.next();
        ArrayList<String> l = new ArrayList<>();
        int diffCnt = 0;
        int cnt = 0;
        for (int i = 0; i < S.length(); i++) {
            l.add(String.valueOf(S.charAt(i)));
        }
        Collections.sort(l);

        for (int i = 0; i < l.size() - 1; i++) {
            if (l.get(i).equals(l.get(i + 1))) {
                diffCnt++;
            }
        }

        System.out.println(diffCnt == 2 ? "Yes" : "No");
    }

} import java.lang.reflect.Array; Array java.lang.reflect import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Comparator; Comparator java.util 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();
        ArrayList<String> l = new ArrayList<>();
        int diffCnt = 0;
        int cnt = 0;
        for (int i = 0; i < S.length(); i++) {
            l.add(String.valueOf(S.charAt(i)));
        }
        Collections.sort(l);

        for (int i = 0; i < l.size() - 1; i++) {
            if (l.get(i).equals(l.get(i + 1))) {
                diffCnt++;
            }
        }

        System.out.println(diffCnt == 2 ? "Yes" : "No");
    }

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

        String S = sc.next();
        ArrayList<String> l = new ArrayList<>();
        int diffCnt = 0;
        int cnt = 0;
        for (int i = 0; i < S.length(); i++) {
            l.add(String.valueOf(S.charAt(i)));
        }
        Collections.sort(l);

        for (int i = 0; i < l.size() - 1; i++) {
            if (l.get(i).equals(l.get(i + 1))) {
                diffCnt++;
            }
        }

        System.out.println(diffCnt == 2 ? "Yes" : "No");
    } main {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        ArrayList<String> l = new ArrayList<>();
        int diffCnt = 0;
        int cnt = 0;
        for (int i = 0; i < S.length(); i++) {
            l.add(String.valueOf(S.charAt(i)));
        }
        Collections.sort(l);

        for (int i = 0; i < l.size() - 1; i++) {
            if (l.get(i).equals(l.get(i + 1))) {
                diffCnt++;
            }
        }

        System.out.println(diffCnt == 2 ? "Yes" : "No");
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc ArrayList<String> l = new ArrayList<>(); l new ArrayList<>() int diffCnt = 0; diffCnt 0 int cnt = 0; cnt 0 for (int i = 0; i < S.length(); i++) {
            l.add(String.valueOf(S.charAt(i)));
        } int i = 0; int i = 0; i 0 i < S.length() i S.length() S.length S i++ i++ i {
            l.add(String.valueOf(S.charAt(i)));
        } {
            l.add(String.valueOf(S.charAt(i)));
        } l.add(String.valueOf(S.charAt(i))) l.add l String.valueOf(S.charAt(i)) String.valueOf String S.charAt(i) S.charAt S i Collections.sort(l) Collections.sort Collections l for (int i = 0; i < l.size() - 1; i++) {
            if (l.get(i).equals(l.get(i + 1))) {
                diffCnt++;
            }
        } int i = 0; int i = 0; i 0 i < l.size() - 1 i l.size() - 1 l.size() l.size l 1 i++ i++ i {
            if (l.get(i).equals(l.get(i + 1))) {
                diffCnt++;
            }
        } {
            if (l.get(i).equals(l.get(i + 1))) {
                diffCnt++;
            }
        } if (l.get(i).equals(l.get(i + 1))) {
                diffCnt++;
            } l.get(i).equals(l.get(i + 1)) l.get(i).equals l.get(i) l.get l i l.get(i + 1) l.get l i + 1 i 1 {
                diffCnt++;
            } diffCnt++ diffCnt System.out.println(diffCnt == 2 ? "Yes" : "No") System.out.println System.out System System.out diffCnt == 2 ? "Yes" : "No" diffCnt == 2 diffCnt 2 "Yes" "No" String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        ArrayList<String> l = new ArrayList<>();
        int diffCnt = 0;
        int cnt = 0;
        for (int i = 0; i < S.length(); i++) {
            l.add(String.valueOf(S.charAt(i)));
        }
        Collections.sort(l);

        for (int i = 0; i < l.size() - 1; i++) {
            if (l.get(i).equals(l.get(i + 1))) {
                diffCnt++;
            }
        }

        System.out.println(diffCnt == 2 ? "Yes" : "No");
    }

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

        String S = sc.next();
        ArrayList<String> l = new ArrayList<>();
        int diffCnt = 0;
        int cnt = 0;
        for (int i = 0; i < S.length(); i++) {
            l.add(String.valueOf(S.charAt(i)));
        }
        Collections.sort(l);

        for (int i = 0; i < l.size() - 1; i++) {
            if (l.get(i).equals(l.get(i + 1))) {
                diffCnt++;
            }
        }

        System.out.println(diffCnt == 2 ? "Yes" : "No");
    }

} Main
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

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

        String S = sc.next();
        ArrayList<String> l = new ArrayList<>();
        int diffCnt = 0;
        int cnt = 0;
        for (int i = 0; i < S.length(); i++) {
            l.add(String.valueOf(S.charAt(i)));
        }
        Collections.sort(l);

        for (int i = 0; i < l.size() - 1; i++) {
            if (l.get(i).equals(l.get(i + 1))) {
                diffCnt++;
            }
        }

        System.out.println(diffCnt == 2 ? "Yes" : "No");
    }

}
