import java.util.Scanner;

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

    Scanner sc = new Scanner(System.in);
    String source = sc.next();

    char[] type = new char[2];

    type[0] = source.charAt(0);

    int count = 1;
    for (int sceIdx = 1; sceIdx < source.length(); sceIdx++) {
      if (source.charAt(sceIdx) != type[0]) { // 0文字目と違う?
        type[1]=source.charAt(sceIdx);
      }else{
        count++;
      }
    }
    if(count!=2||type[1]=='\0'){
      System.out.println("No");
      return;
    }
    count = 0;
    for (int sceIdx = 1; sceIdx < source.length(); sceIdx++) {
      if (source.charAt(sceIdx) == type[1]) {
        count++;
      }
    }
    if(count != 2){
      System.out.println("No");
      return;
    }
    System.out.println("Yes");
    return;
  }

} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String source = sc.next();

    char[] type = new char[2];

    type[0] = source.charAt(0);

    int count = 1;
    for (int sceIdx = 1; sceIdx < source.length(); sceIdx++) {
      if (source.charAt(sceIdx) != type[0]) { // 0文字目と違う?
        type[1]=source.charAt(sceIdx);
      }else{
        count++;
      }
    }
    if(count!=2||type[1]=='\0'){
      System.out.println("No");
      return;
    }
    count = 0;
    for (int sceIdx = 1; sceIdx < source.length(); sceIdx++) {
      if (source.charAt(sceIdx) == type[1]) {
        count++;
      }
    }
    if(count != 2){
      System.out.println("No");
      return;
    }
    System.out.println("Yes");
    return;
  }

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

    Scanner sc = new Scanner(System.in);
    String source = sc.next();

    char[] type = new char[2];

    type[0] = source.charAt(0);

    int count = 1;
    for (int sceIdx = 1; sceIdx < source.length(); sceIdx++) {
      if (source.charAt(sceIdx) != type[0]) { // 0文字目と違う?
        type[1]=source.charAt(sceIdx);
      }else{
        count++;
      }
    }
    if(count!=2||type[1]=='\0'){
      System.out.println("No");
      return;
    }
    count = 0;
    for (int sceIdx = 1; sceIdx < source.length(); sceIdx++) {
      if (source.charAt(sceIdx) == type[1]) {
        count++;
      }
    }
    if(count != 2){
      System.out.println("No");
      return;
    }
    System.out.println("Yes");
    return;
  } main {

    Scanner sc = new Scanner(System.in);
    String source = sc.next();

    char[] type = new char[2];

    type[0] = source.charAt(0);

    int count = 1;
    for (int sceIdx = 1; sceIdx < source.length(); sceIdx++) {
      if (source.charAt(sceIdx) != type[0]) { // 0文字目と違う?
        type[1]=source.charAt(sceIdx);
      }else{
        count++;
      }
    }
    if(count!=2||type[1]=='\0'){
      System.out.println("No");
      return;
    }
    count = 0;
    for (int sceIdx = 1; sceIdx < source.length(); sceIdx++) {
      if (source.charAt(sceIdx) == type[1]) {
        count++;
      }
    }
    if(count != 2){
      System.out.println("No");
      return;
    }
    System.out.println("Yes");
    return;
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String source = sc.next(); source sc.next() sc.next sc char[] type = new char[2]; type new char[2] 2 type[0] = source.charAt(0) type[0] type 0 source.charAt(0) source.charAt source 0 int count = 1; count 1 for (int sceIdx = 1; sceIdx < source.length(); sceIdx++) {
      if (source.charAt(sceIdx) != type[0]) { // 0文字目と違う?
        type[1]=source.charAt(sceIdx);
      }else{
        count++;
      }
    } int sceIdx = 1; int sceIdx = 1; sceIdx 1 sceIdx < source.length() sceIdx source.length() source.length source sceIdx++ sceIdx++ sceIdx {
      if (source.charAt(sceIdx) != type[0]) { // 0文字目と違う?
        type[1]=source.charAt(sceIdx);
      }else{
        count++;
      }
    } {
      if (source.charAt(sceIdx) != type[0]) { // 0文字目と違う?
        type[1]=source.charAt(sceIdx);
      }else{
        count++;
      }
    } if (source.charAt(sceIdx) != type[0]) { // 0文字目と違う?
        type[1]=source.charAt(sceIdx);
      }else{
        count++;
      } source.charAt(sceIdx) != type[0] source.charAt(sceIdx) source.charAt source sceIdx type[0] type 0 { // 0文字目と違う?
        type[1]=source.charAt(sceIdx);
      } type[1]=source.charAt(sceIdx) type[1] type 1 source.charAt(sceIdx) source.charAt source sceIdx {
        count++;
      } count++ count if(count!=2||type[1]=='\0'){
      System.out.println("No");
      return;
    } count!=2||type[1]=='\0' count!=2 count 2 type[1]=='\0' type[1] type 1 '\0' {
      System.out.println("No");
      return;
    } System.out.println("No") System.out.println System.out System System.out "No" return; count = 0 count 0 for (int sceIdx = 1; sceIdx < source.length(); sceIdx++) {
      if (source.charAt(sceIdx) == type[1]) {
        count++;
      }
    } int sceIdx = 1; int sceIdx = 1; sceIdx 1 sceIdx < source.length() sceIdx source.length() source.length source sceIdx++ sceIdx++ sceIdx {
      if (source.charAt(sceIdx) == type[1]) {
        count++;
      }
    } {
      if (source.charAt(sceIdx) == type[1]) {
        count++;
      }
    } if (source.charAt(sceIdx) == type[1]) {
        count++;
      } source.charAt(sceIdx) == type[1] source.charAt(sceIdx) source.charAt source sceIdx type[1] type 1 {
        count++;
      } count++ count if(count != 2){
      System.out.println("No");
      return;
    } count != 2 count 2 {
      System.out.println("No");
      return;
    } System.out.println("No") System.out.println System.out System System.out "No" return; System.out.println("Yes") System.out.println System.out System System.out "Yes" return; String[] args args public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String source = sc.next();

    char[] type = new char[2];

    type[0] = source.charAt(0);

    int count = 1;
    for (int sceIdx = 1; sceIdx < source.length(); sceIdx++) {
      if (source.charAt(sceIdx) != type[0]) { // 0文字目と違う?
        type[1]=source.charAt(sceIdx);
      }else{
        count++;
      }
    }
    if(count!=2||type[1]=='\0'){
      System.out.println("No");
      return;
    }
    count = 0;
    for (int sceIdx = 1; sceIdx < source.length(); sceIdx++) {
      if (source.charAt(sceIdx) == type[1]) {
        count++;
      }
    }
    if(count != 2){
      System.out.println("No");
      return;
    }
    System.out.println("Yes");
    return;
  }

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

    Scanner sc = new Scanner(System.in);
    String source = sc.next();

    char[] type = new char[2];

    type[0] = source.charAt(0);

    int count = 1;
    for (int sceIdx = 1; sceIdx < source.length(); sceIdx++) {
      if (source.charAt(sceIdx) != type[0]) { // 0文字目と違う?
        type[1]=source.charAt(sceIdx);
      }else{
        count++;
      }
    }
    if(count!=2||type[1]=='\0'){
      System.out.println("No");
      return;
    }
    count = 0;
    for (int sceIdx = 1; sceIdx < source.length(); sceIdx++) {
      if (source.charAt(sceIdx) == type[1]) {
        count++;
      }
    }
    if(count != 2){
      System.out.println("No");
      return;
    }
    System.out.println("Yes");
    return;
  }

} Main
import java.util.Scanner;

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

    Scanner sc = new Scanner(System.in);
    String source = sc.next();

    char[] type = new char[2];

    type[0] = source.charAt(0);

    int count = 1;
    for (int sceIdx = 1; sceIdx < source.length(); sceIdx++) {
      if (source.charAt(sceIdx) != type[0]) { // 0文字目と違う?
        type[1]=source.charAt(sceIdx);
      }else{
        count++;
      }
    }
    if(count!=2||type[1]=='\0'){
      System.out.println("No");
      return;
    }
    count = 0;
    for (int sceIdx = 1; sceIdx < source.length(); sceIdx++) {
      if (source.charAt(sceIdx) == type[1]) {
        count++;
      }
    }
    if(count != 2){
      System.out.println("No");
      return;
    }
    System.out.println("Yes");
    return;
  }

}