import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);
    String S = scan.nextLine();
    String tmp = S.replace(String.valueOf(S.charAt(0)), "");
    if (tmp.length() == 2 && tmp.charAt(0) == tmp.charAt(1)) {
      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 scan = new Scanner(System.in);
    String S = scan.nextLine();
    String tmp = S.replace(String.valueOf(S.charAt(0)), "");
    if (tmp.length() == 2 && tmp.charAt(0) == tmp.charAt(1)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
} Main public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);
    String S = scan.nextLine();
    String tmp = S.replace(String.valueOf(S.charAt(0)), "");
    if (tmp.length() == 2 && tmp.charAt(0) == tmp.charAt(1)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  } main {

    Scanner scan = new Scanner(System.in);
    String S = scan.nextLine();
    String tmp = S.replace(String.valueOf(S.charAt(0)), "");
    if (tmp.length() == 2 && tmp.charAt(0) == tmp.charAt(1)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String S = scan.nextLine(); S scan.nextLine() scan.nextLine scan String tmp = S.replace(String.valueOf(S.charAt(0)), ""); tmp S.replace(String.valueOf(S.charAt(0)), "") S.replace S String.valueOf(S.charAt(0)) String.valueOf String S.charAt(0) S.charAt S 0 "" if (tmp.length() == 2 && tmp.charAt(0) == tmp.charAt(1)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    } tmp.length() == 2 && tmp.charAt(0) == tmp.charAt(1) tmp.length() == 2 tmp.length() tmp.length tmp 2 tmp.charAt(0) == tmp.charAt(1) tmp.charAt(0) tmp.charAt tmp 0 tmp.charAt(1) tmp.charAt tmp 1 {
      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 scan = new Scanner(System.in);
    String S = scan.nextLine();
    String tmp = S.replace(String.valueOf(S.charAt(0)), "");
    if (tmp.length() == 2 && tmp.charAt(0) == tmp.charAt(1)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
} public class Main {
  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);
    String S = scan.nextLine();
    String tmp = S.replace(String.valueOf(S.charAt(0)), "");
    if (tmp.length() == 2 && tmp.charAt(0) == tmp.charAt(1)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);
    String S = scan.nextLine();
    String tmp = S.replace(String.valueOf(S.charAt(0)), "");
    if (tmp.length() == 2 && tmp.charAt(0) == tmp.charAt(1)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}
