import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std  = new Scanner(System.in);
        String s = std.next();
        String[] split = s.split("");
        long count = Arrays.stream(split).distinct().count();
        String rest = s.replaceAll(split[0], "");
        boolean isSame = rest.length() == 2;
        if (count == 2 && isSame) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner std  = new Scanner(System.in);
        String s = std.next();
        String[] split = s.split("");
        long count = Arrays.stream(split).distinct().count();
        String rest = s.replaceAll(split[0], "");
        boolean isSame = rest.length() == 2;
        if (count == 2 && isSame) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} Main public static void main(String[] args) {
        Scanner std  = new Scanner(System.in);
        String s = std.next();
        String[] split = s.split("");
        long count = Arrays.stream(split).distinct().count();
        String rest = s.replaceAll(split[0], "");
        boolean isSame = rest.length() == 2;
        if (count == 2 && isSame) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    } main {
        Scanner std  = new Scanner(System.in);
        String s = std.next();
        String[] split = s.split("");
        long count = Arrays.stream(split).distinct().count();
        String rest = s.replaceAll(split[0], "");
        boolean isSame = rest.length() == 2;
        if (count == 2 && isSame) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    } Scanner std  = new Scanner(System.in); std new Scanner(System.in) String s = std.next(); s std.next() std.next std String[] split = s.split(""); split s.split("") s.split s "" long count = Arrays.stream(split).distinct().count(); count Arrays.stream(split).distinct().count() Arrays.stream(split).distinct().count Arrays.stream(split).distinct() Arrays.stream(split).distinct Arrays.stream(split) Arrays.stream Arrays split String rest = s.replaceAll(split[0], ""); rest s.replaceAll(split[0], "") s.replaceAll s split[0] split 0 "" boolean isSame = rest.length() == 2; isSame rest.length() == 2 rest.length() rest.length rest 2 if (count == 2 && isSame) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        } count == 2 && isSame count == 2 count 2 isSame {
            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 std  = new Scanner(System.in);
        String s = std.next();
        String[] split = s.split("");
        long count = Arrays.stream(split).distinct().count();
        String rest = s.replaceAll(split[0], "");
        boolean isSame = rest.length() == 2;
        if (count == 2 && isSame) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner std  = new Scanner(System.in);
        String s = std.next();
        String[] split = s.split("");
        long count = Arrays.stream(split).distinct().count();
        String rest = s.replaceAll(split[0], "");
        boolean isSame = rest.length() == 2;
        if (count == 2 && isSame) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std  = new Scanner(System.in);
        String s = std.next();
        String[] split = s.split("");
        long count = Arrays.stream(split).distinct().count();
        String rest = s.replaceAll(split[0], "");
        boolean isSame = rest.length() == 2;
        if (count == 2 && isSame) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}
