import java.util.*;
public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    Map<Character, Integer> map = new HashMap<>();
    for (int i = 0; i < 4; i++) {
      char c = S.charAt(i);
      int count = map.getOrDefault(c, 0);
      map.put(c, ++count) ;
    }
    if (map.size() != 2) {
      System.out.println("No");
      return;
    }
    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
      if (entry.getValue() != 2) {
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  }  
} import java.util.*; util.* java public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    Map<Character, Integer> map = new HashMap<>();
    for (int i = 0; i < 4; i++) {
      char c = S.charAt(i);
      int count = map.getOrDefault(c, 0);
      map.put(c, ++count) ;
    }
    if (map.size() != 2) {
      System.out.println("No");
      return;
    }
    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
      if (entry.getValue() != 2) {
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  }  
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    Map<Character, Integer> map = new HashMap<>();
    for (int i = 0; i < 4; i++) {
      char c = S.charAt(i);
      int count = map.getOrDefault(c, 0);
      map.put(c, ++count) ;
    }
    if (map.size() != 2) {
      System.out.println("No");
      return;
    }
    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
      if (entry.getValue() != 2) {
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  } main {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    Map<Character, Integer> map = new HashMap<>();
    for (int i = 0; i < 4; i++) {
      char c = S.charAt(i);
      int count = map.getOrDefault(c, 0);
      map.put(c, ++count) ;
    }
    if (map.size() != 2) {
      System.out.println("No");
      return;
    }
    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
      if (entry.getValue() != 2) {
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc Map<Character, Integer> map = new HashMap<>(); map new HashMap<>() for (int i = 0; i < 4; i++) {
      char c = S.charAt(i);
      int count = map.getOrDefault(c, 0);
      map.put(c, ++count) ;
    } int i = 0; int i = 0; i 0 i < 4 i 4 i++ i++ i {
      char c = S.charAt(i);
      int count = map.getOrDefault(c, 0);
      map.put(c, ++count) ;
    } {
      char c = S.charAt(i);
      int count = map.getOrDefault(c, 0);
      map.put(c, ++count) ;
    } char c = S.charAt(i); c S.charAt(i) S.charAt S i int count = map.getOrDefault(c, 0); count map.getOrDefault(c, 0) map.getOrDefault map c 0 map.put(c, ++count) map.put map c ++count count if (map.size() != 2) {
      System.out.println("No");
      return;
    } map.size() != 2 map.size() map.size map 2 {
      System.out.println("No");
      return;
    } System.out.println("No") System.out.println System.out System System.out "No" return; for (Map.Entry<Character, Integer> entry : map.entrySet()) {
      if (entry.getValue() != 2) {
        System.out.println("No");
        return;
      }
    } Map.Entry<Character, Integer> entry map.entrySet() map.entrySet map {
      if (entry.getValue() != 2) {
        System.out.println("No");
        return;
      }
    } {
      if (entry.getValue() != 2) {
        System.out.println("No");
        return;
      }
    } if (entry.getValue() != 2) {
        System.out.println("No");
        return;
      } entry.getValue() != 2 entry.getValue() entry.getValue entry 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" String[] args args public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    Map<Character, Integer> map = new HashMap<>();
    for (int i = 0; i < 4; i++) {
      char c = S.charAt(i);
      int count = map.getOrDefault(c, 0);
      map.put(c, ++count) ;
    }
    if (map.size() != 2) {
      System.out.println("No");
      return;
    }
    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
      if (entry.getValue() != 2) {
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  }  
} public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    Map<Character, Integer> map = new HashMap<>();
    for (int i = 0; i < 4; i++) {
      char c = S.charAt(i);
      int count = map.getOrDefault(c, 0);
      map.put(c, ++count) ;
    }
    if (map.size() != 2) {
      System.out.println("No");
      return;
    }
    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
      if (entry.getValue() != 2) {
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  }  
} Main
import java.util.*;
public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    Map<Character, Integer> map = new HashMap<>();
    for (int i = 0; i < 4; i++) {
      char c = S.charAt(i);
      int count = map.getOrDefault(c, 0);
      map.put(c, ++count) ;
    }
    if (map.size() != 2) {
      System.out.println("No");
      return;
    }
    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
      if (entry.getValue() != 2) {
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  }  
}