import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int[] alp = new int[26];
    String s = sc.next();
    int cnt = 0;

    for (int i = 0; i < 4; i++) {
      alp[s.charAt(i) - 'A']++;
    }

    for (int i = 0; i < 26; i++) {
      if (alp[i] == 0) {
        continue;
      } else if (alp[i] == 2) {
        cnt++;
      } else {
        System.out.println("No");
        return;
      }
    }

    if (cnt == 2) {
      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 sc = new Scanner(System.in);

    int[] alp = new int[26];
    String s = sc.next();
    int cnt = 0;

    for (int i = 0; i < 4; i++) {
      alp[s.charAt(i) - 'A']++;
    }

    for (int i = 0; i < 26; i++) {
      if (alp[i] == 0) {
        continue;
      } else if (alp[i] == 2) {
        cnt++;
      } else {
        System.out.println("No");
        return;
      }
    }

    if (cnt == 2) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

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

    Scanner sc = new Scanner(System.in);

    int[] alp = new int[26];
    String s = sc.next();
    int cnt = 0;

    for (int i = 0; i < 4; i++) {
      alp[s.charAt(i) - 'A']++;
    }

    for (int i = 0; i < 26; i++) {
      if (alp[i] == 0) {
        continue;
      } else if (alp[i] == 2) {
        cnt++;
      } else {
        System.out.println("No");
        return;
      }
    }

    if (cnt == 2) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  } main {

    Scanner sc = new Scanner(System.in);

    int[] alp = new int[26];
    String s = sc.next();
    int cnt = 0;

    for (int i = 0; i < 4; i++) {
      alp[s.charAt(i) - 'A']++;
    }

    for (int i = 0; i < 26; i++) {
      if (alp[i] == 0) {
        continue;
      } else if (alp[i] == 2) {
        cnt++;
      } else {
        System.out.println("No");
        return;
      }
    }

    if (cnt == 2) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int[] alp = new int[26]; alp new int[26] 26 String s = sc.next(); s sc.next() sc.next sc int cnt = 0; cnt 0 for (int i = 0; i < 4; i++) {
      alp[s.charAt(i) - 'A']++;
    } int i = 0; int i = 0; i 0 i < 4 i 4 i++ i++ i {
      alp[s.charAt(i) - 'A']++;
    } {
      alp[s.charAt(i) - 'A']++;
    } alp[s.charAt(i) - 'A']++ alp[s.charAt(i) - 'A'] alp s.charAt(i) - 'A' s.charAt(i) s.charAt s i 'A' for (int i = 0; i < 26; i++) {
      if (alp[i] == 0) {
        continue;
      } else if (alp[i] == 2) {
        cnt++;
      } else {
        System.out.println("No");
        return;
      }
    } int i = 0; int i = 0; i 0 i < 26 i 26 i++ i++ i {
      if (alp[i] == 0) {
        continue;
      } else if (alp[i] == 2) {
        cnt++;
      } else {
        System.out.println("No");
        return;
      }
    } {
      if (alp[i] == 0) {
        continue;
      } else if (alp[i] == 2) {
        cnt++;
      } else {
        System.out.println("No");
        return;
      }
    } if (alp[i] == 0) {
        continue;
      } else if (alp[i] == 2) {
        cnt++;
      } else {
        System.out.println("No");
        return;
      } alp[i] == 0 alp[i] alp i 0 {
        continue;
      } continue; if (alp[i] == 2) {
        cnt++;
      } else {
        System.out.println("No");
        return;
      } alp[i] == 2 alp[i] alp i 2 {
        cnt++;
      } cnt++ cnt {
        System.out.println("No");
        return;
      } System.out.println("No") System.out.println System.out System System.out "No" return; if (cnt == 2) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    } cnt == 2 cnt 2 {
      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 sc = new Scanner(System.in);

    int[] alp = new int[26];
    String s = sc.next();
    int cnt = 0;

    for (int i = 0; i < 4; i++) {
      alp[s.charAt(i) - 'A']++;
    }

    for (int i = 0; i < 26; i++) {
      if (alp[i] == 0) {
        continue;
      } else if (alp[i] == 2) {
        cnt++;
      } else {
        System.out.println("No");
        return;
      }
    }

    if (cnt == 2) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
} public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int[] alp = new int[26];
    String s = sc.next();
    int cnt = 0;

    for (int i = 0; i < 4; i++) {
      alp[s.charAt(i) - 'A']++;
    }

    for (int i = 0; i < 26; i++) {
      if (alp[i] == 0) {
        continue;
      } else if (alp[i] == 2) {
        cnt++;
      } else {
        System.out.println("No");
        return;
      }
    }

    if (cnt == 2) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
} Main
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int[] alp = new int[26];
    String s = sc.next();
    int cnt = 0;

    for (int i = 0; i < 4; i++) {
      alp[s.charAt(i) - 'A']++;
    }

    for (int i = 0; i < 26; i++) {
      if (alp[i] == 0) {
        continue;
      } else if (alp[i] == 2) {
        cnt++;
      } else {
        System.out.println("No");
        return;
      }
    }

    if (cnt == 2) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}