import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Objects;

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

    Scanner sc = new Scanner(System.in);

    String S = sc.next();
    List<Character> chList = new ArrayList<Character>();
    List<Integer> intList = new ArrayList<Integer>();

    for (int i = 0; i < S.length(); i++) {
      if (chList.contains(S.charAt(i))){
        int index = chList.indexOf(S.charAt(i));
        intList.set(index, intList.get(index) + 1);
      } else {
        intList.add(1);
        chList.add(S.charAt(i));
      }
    }

    boolean flag = true;
    if (intList.size() != 2) flag = false;
    else if(intList.get(0).intValue() != 2 || intList.get(1).intValue() != 2) flag = false;

    System.out.println(flag ? "Yes" : "No");

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

    Scanner sc = new Scanner(System.in);

    String S = sc.next();
    List<Character> chList = new ArrayList<Character>();
    List<Integer> intList = new ArrayList<Integer>();

    for (int i = 0; i < S.length(); i++) {
      if (chList.contains(S.charAt(i))){
        int index = chList.indexOf(S.charAt(i));
        intList.set(index, intList.get(index) + 1);
      } else {
        intList.add(1);
        chList.add(S.charAt(i));
      }
    }

    boolean flag = true;
    if (intList.size() != 2) flag = false;
    else if(intList.get(0).intValue() != 2 || intList.get(1).intValue() != 2) flag = false;

    System.out.println(flag ? "Yes" : "No");

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

    Scanner sc = new Scanner(System.in);

    String S = sc.next();
    List<Character> chList = new ArrayList<Character>();
    List<Integer> intList = new ArrayList<Integer>();

    for (int i = 0; i < S.length(); i++) {
      if (chList.contains(S.charAt(i))){
        int index = chList.indexOf(S.charAt(i));
        intList.set(index, intList.get(index) + 1);
      } else {
        intList.add(1);
        chList.add(S.charAt(i));
      }
    }

    boolean flag = true;
    if (intList.size() != 2) flag = false;
    else if(intList.get(0).intValue() != 2 || intList.get(1).intValue() != 2) flag = false;

    System.out.println(flag ? "Yes" : "No");

  } main {

    Scanner sc = new Scanner(System.in);

    String S = sc.next();
    List<Character> chList = new ArrayList<Character>();
    List<Integer> intList = new ArrayList<Integer>();

    for (int i = 0; i < S.length(); i++) {
      if (chList.contains(S.charAt(i))){
        int index = chList.indexOf(S.charAt(i));
        intList.set(index, intList.get(index) + 1);
      } else {
        intList.add(1);
        chList.add(S.charAt(i));
      }
    }

    boolean flag = true;
    if (intList.size() != 2) flag = false;
    else if(intList.get(0).intValue() != 2 || intList.get(1).intValue() != 2) flag = false;

    System.out.println(flag ? "Yes" : "No");

  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc List<Character> chList = new ArrayList<Character>(); chList new ArrayList<Character>() List<Integer> intList = new ArrayList<Integer>(); intList new ArrayList<Integer>() for (int i = 0; i < S.length(); i++) {
      if (chList.contains(S.charAt(i))){
        int index = chList.indexOf(S.charAt(i));
        intList.set(index, intList.get(index) + 1);
      } else {
        intList.add(1);
        chList.add(S.charAt(i));
      }
    } int i = 0; int i = 0; i 0 i < S.length() i S.length() S.length S i++ i++ i {
      if (chList.contains(S.charAt(i))){
        int index = chList.indexOf(S.charAt(i));
        intList.set(index, intList.get(index) + 1);
      } else {
        intList.add(1);
        chList.add(S.charAt(i));
      }
    } {
      if (chList.contains(S.charAt(i))){
        int index = chList.indexOf(S.charAt(i));
        intList.set(index, intList.get(index) + 1);
      } else {
        intList.add(1);
        chList.add(S.charAt(i));
      }
    } if (chList.contains(S.charAt(i))){
        int index = chList.indexOf(S.charAt(i));
        intList.set(index, intList.get(index) + 1);
      } else {
        intList.add(1);
        chList.add(S.charAt(i));
      } chList.contains(S.charAt(i)) chList.contains chList S.charAt(i) S.charAt S i {
        int index = chList.indexOf(S.charAt(i));
        intList.set(index, intList.get(index) + 1);
      } int index = chList.indexOf(S.charAt(i)); index chList.indexOf(S.charAt(i)) chList.indexOf chList S.charAt(i) S.charAt S i intList.set(index, intList.get(index) + 1) intList.set intList index intList.get(index) + 1 intList.get(index) intList.get intList index 1 {
        intList.add(1);
        chList.add(S.charAt(i));
      } intList.add(1) intList.add intList 1 chList.add(S.charAt(i)) chList.add chList S.charAt(i) S.charAt S i boolean flag = true; flag true if (intList.size() != 2) flag = false;
    else if(intList.get(0).intValue() != 2 || intList.get(1).intValue() != 2) flag = false; intList.size() != 2 intList.size() intList.size intList 2 flag = false flag false if(intList.get(0).intValue() != 2 || intList.get(1).intValue() != 2) flag = false; intList.get(0).intValue() != 2 || intList.get(1).intValue() != 2 intList.get(0).intValue() != 2 intList.get(0).intValue() intList.get(0).intValue intList.get(0) intList.get intList 0 2 intList.get(1).intValue() != 2 intList.get(1).intValue() intList.get(1).intValue intList.get(1) intList.get intList 1 2 flag = false flag false System.out.println(flag ? "Yes" : "No") System.out.println System.out System System.out flag ? "Yes" : "No" flag "Yes" "No" String[] args args public class Main {
  public static void main(String[] args ){

    Scanner sc = new Scanner(System.in);

    String S = sc.next();
    List<Character> chList = new ArrayList<Character>();
    List<Integer> intList = new ArrayList<Integer>();

    for (int i = 0; i < S.length(); i++) {
      if (chList.contains(S.charAt(i))){
        int index = chList.indexOf(S.charAt(i));
        intList.set(index, intList.get(index) + 1);
      } else {
        intList.add(1);
        chList.add(S.charAt(i));
      }
    }

    boolean flag = true;
    if (intList.size() != 2) flag = false;
    else if(intList.get(0).intValue() != 2 || intList.get(1).intValue() != 2) flag = false;

    System.out.println(flag ? "Yes" : "No");

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

    Scanner sc = new Scanner(System.in);

    String S = sc.next();
    List<Character> chList = new ArrayList<Character>();
    List<Integer> intList = new ArrayList<Integer>();

    for (int i = 0; i < S.length(); i++) {
      if (chList.contains(S.charAt(i))){
        int index = chList.indexOf(S.charAt(i));
        intList.set(index, intList.get(index) + 1);
      } else {
        intList.add(1);
        chList.add(S.charAt(i));
      }
    }

    boolean flag = true;
    if (intList.size() != 2) flag = false;
    else if(intList.get(0).intValue() != 2 || intList.get(1).intValue() != 2) flag = false;

    System.out.println(flag ? "Yes" : "No");

  }
} Main
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Objects;

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

    Scanner sc = new Scanner(System.in);

    String S = sc.next();
    List<Character> chList = new ArrayList<Character>();
    List<Integer> intList = new ArrayList<Integer>();

    for (int i = 0; i < S.length(); i++) {
      if (chList.contains(S.charAt(i))){
        int index = chList.indexOf(S.charAt(i));
        intList.set(index, intList.get(index) + 1);
      } else {
        intList.add(1);
        chList.add(S.charAt(i));
      }
    }

    boolean flag = true;
    if (intList.size() != 2) flag = false;
    else if(intList.get(0).intValue() != 2 || intList.get(1).intValue() != 2) flag = false;

    System.out.println(flag ? "Yes" : "No");

  }
}
