import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();

    String a = s.substring(0, 1);
    String b = s.substring(1, 2);
    String c = s.substring(2, 3);
    String d = s.substring(3, 4);

    String ans = "No";
    if (a.equals(b) && c.equals(d) && !(a.equals(c))) ans = "Yes";
    if (a.equals(c) && b.equals(d) && !(a.equals(b))) ans = "Yes";
    if (a.equals(d) && b.equals(c) && !(a.equals(b))) ans = "Yes";
    
    System.out.println(ans);
  }
} import java.util.*; util.* java public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();

    String a = s.substring(0, 1);
    String b = s.substring(1, 2);
    String c = s.substring(2, 3);
    String d = s.substring(3, 4);

    String ans = "No";
    if (a.equals(b) && c.equals(d) && !(a.equals(c))) ans = "Yes";
    if (a.equals(c) && b.equals(d) && !(a.equals(b))) ans = "Yes";
    if (a.equals(d) && b.equals(c) && !(a.equals(b))) ans = "Yes";
    
    System.out.println(ans);
  }
} Main public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();

    String a = s.substring(0, 1);
    String b = s.substring(1, 2);
    String c = s.substring(2, 3);
    String d = s.substring(3, 4);

    String ans = "No";
    if (a.equals(b) && c.equals(d) && !(a.equals(c))) ans = "Yes";
    if (a.equals(c) && b.equals(d) && !(a.equals(b))) ans = "Yes";
    if (a.equals(d) && b.equals(c) && !(a.equals(b))) ans = "Yes";
    
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();

    String a = s.substring(0, 1);
    String b = s.substring(1, 2);
    String c = s.substring(2, 3);
    String d = s.substring(3, 4);

    String ans = "No";
    if (a.equals(b) && c.equals(d) && !(a.equals(c))) ans = "Yes";
    if (a.equals(c) && b.equals(d) && !(a.equals(b))) ans = "Yes";
    if (a.equals(d) && b.equals(c) && !(a.equals(b))) ans = "Yes";
    
    System.out.println(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc String a = s.substring(0, 1); a s.substring(0, 1) s.substring s 0 1 String b = s.substring(1, 2); b s.substring(1, 2) s.substring s 1 2 String c = s.substring(2, 3); c s.substring(2, 3) s.substring s 2 3 String d = s.substring(3, 4); d s.substring(3, 4) s.substring s 3 4 String ans = "No"; ans "No" if (a.equals(b) && c.equals(d) && !(a.equals(c))) ans = "Yes"; a.equals(b) && c.equals(d) && !(a.equals(c)) a.equals(b) && c.equals(d) && !(a.equals(c)) a.equals(b) a.equals a b c.equals(d) c.equals c d !(a.equals(c)) (a.equals(c)) a.equals a c ans = "Yes" ans "Yes" if (a.equals(c) && b.equals(d) && !(a.equals(b))) ans = "Yes"; a.equals(c) && b.equals(d) && !(a.equals(b)) a.equals(c) && b.equals(d) && !(a.equals(b)) a.equals(c) a.equals a c b.equals(d) b.equals b d !(a.equals(b)) (a.equals(b)) a.equals a b ans = "Yes" ans "Yes" if (a.equals(d) && b.equals(c) && !(a.equals(b))) ans = "Yes"; a.equals(d) && b.equals(c) && !(a.equals(b)) a.equals(d) && b.equals(c) && !(a.equals(b)) a.equals(d) a.equals a d b.equals(c) b.equals b c !(a.equals(b)) (a.equals(b)) a.equals a b ans = "Yes" ans "Yes" System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();

    String a = s.substring(0, 1);
    String b = s.substring(1, 2);
    String c = s.substring(2, 3);
    String d = s.substring(3, 4);

    String ans = "No";
    if (a.equals(b) && c.equals(d) && !(a.equals(c))) ans = "Yes";
    if (a.equals(c) && b.equals(d) && !(a.equals(b))) ans = "Yes";
    if (a.equals(d) && b.equals(c) && !(a.equals(b))) ans = "Yes";
    
    System.out.println(ans);
  }
} public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();

    String a = s.substring(0, 1);
    String b = s.substring(1, 2);
    String c = s.substring(2, 3);
    String d = s.substring(3, 4);

    String ans = "No";
    if (a.equals(b) && c.equals(d) && !(a.equals(c))) ans = "Yes";
    if (a.equals(c) && b.equals(d) && !(a.equals(b))) ans = "Yes";
    if (a.equals(d) && b.equals(c) && !(a.equals(b))) ans = "Yes";
    
    System.out.println(ans);
  }
} Main
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();

    String a = s.substring(0, 1);
    String b = s.substring(1, 2);
    String c = s.substring(2, 3);
    String d = s.substring(3, 4);

    String ans = "No";
    if (a.equals(b) && c.equals(d) && !(a.equals(c))) ans = "Yes";
    if (a.equals(c) && b.equals(d) && !(a.equals(b))) ans = "Yes";
    if (a.equals(d) && b.equals(c) && !(a.equals(b))) ans = "Yes";
    
    System.out.println(ans);
  }
}
