import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String S1 = S.substring(0,1);
    String S2 = S.substring(1,2);
    String S3 = S.substring(2,3);
    String S4 = S.substring(3,4);
    if (S1.equals(S2) && S3.equals(S4) && !(S1.equals(S3))){
      System.out.println("Yes");
    }else if(S1.equals(S3) && S2.equals(S4) && !(S1.equals(S2))){
      System.out.println("Yes");
    }else if(S1.equals(S4) && S2.equals(S3) && !(S1.equals(S2))){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
} import java.util.*; util.* java class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String S1 = S.substring(0,1);
    String S2 = S.substring(1,2);
    String S3 = S.substring(2,3);
    String S4 = S.substring(3,4);
    if (S1.equals(S2) && S3.equals(S4) && !(S1.equals(S3))){
      System.out.println("Yes");
    }else if(S1.equals(S3) && S2.equals(S4) && !(S1.equals(S2))){
      System.out.println("Yes");
    }else if(S1.equals(S4) && S2.equals(S3) && !(S1.equals(S2))){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String S1 = S.substring(0,1);
    String S2 = S.substring(1,2);
    String S3 = S.substring(2,3);
    String S4 = S.substring(3,4);
    if (S1.equals(S2) && S3.equals(S4) && !(S1.equals(S3))){
      System.out.println("Yes");
    }else if(S1.equals(S3) && S2.equals(S4) && !(S1.equals(S2))){
      System.out.println("Yes");
    }else if(S1.equals(S4) && S2.equals(S3) && !(S1.equals(S2))){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  } main {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String S1 = S.substring(0,1);
    String S2 = S.substring(1,2);
    String S3 = S.substring(2,3);
    String S4 = S.substring(3,4);
    if (S1.equals(S2) && S3.equals(S4) && !(S1.equals(S3))){
      System.out.println("Yes");
    }else if(S1.equals(S3) && S2.equals(S4) && !(S1.equals(S2))){
      System.out.println("Yes");
    }else if(S1.equals(S4) && S2.equals(S3) && !(S1.equals(S2))){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc String S1 = S.substring(0,1); S1 S.substring(0,1) S.substring S 0 1 String S2 = S.substring(1,2); S2 S.substring(1,2) S.substring S 1 2 String S3 = S.substring(2,3); S3 S.substring(2,3) S.substring S 2 3 String S4 = S.substring(3,4); S4 S.substring(3,4) S.substring S 3 4 if (S1.equals(S2) && S3.equals(S4) && !(S1.equals(S3))){
      System.out.println("Yes");
    }else if(S1.equals(S3) && S2.equals(S4) && !(S1.equals(S2))){
      System.out.println("Yes");
    }else if(S1.equals(S4) && S2.equals(S3) && !(S1.equals(S2))){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    } S1.equals(S2) && S3.equals(S4) && !(S1.equals(S3)) S1.equals(S2) && S3.equals(S4) && !(S1.equals(S3)) S1.equals(S2) S1.equals S1 S2 S3.equals(S4) S3.equals S3 S4 !(S1.equals(S3)) (S1.equals(S3)) S1.equals S1 S3 {
      System.out.println("Yes");
    } System.out.println("Yes") System.out.println System.out System System.out "Yes" if(S1.equals(S3) && S2.equals(S4) && !(S1.equals(S2))){
      System.out.println("Yes");
    }else if(S1.equals(S4) && S2.equals(S3) && !(S1.equals(S2))){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    } S1.equals(S3) && S2.equals(S4) && !(S1.equals(S2)) S1.equals(S3) && S2.equals(S4) && !(S1.equals(S2)) S1.equals(S3) S1.equals S1 S3 S2.equals(S4) S2.equals S2 S4 !(S1.equals(S2)) (S1.equals(S2)) S1.equals S1 S2 {
      System.out.println("Yes");
    } System.out.println("Yes") System.out.println System.out System System.out "Yes" if(S1.equals(S4) && S2.equals(S3) && !(S1.equals(S2))){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    } S1.equals(S4) && S2.equals(S3) && !(S1.equals(S2)) S1.equals(S4) && S2.equals(S3) && !(S1.equals(S2)) S1.equals(S4) S1.equals S1 S4 S2.equals(S3) S2.equals S2 S3 !(S1.equals(S2)) (S1.equals(S2)) S1.equals S1 S2 {
      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
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String S1 = S.substring(0,1);
    String S2 = S.substring(1,2);
    String S3 = S.substring(2,3);
    String S4 = S.substring(3,4);
    if (S1.equals(S2) && S3.equals(S4) && !(S1.equals(S3))){
      System.out.println("Yes");
    }else if(S1.equals(S3) && S2.equals(S4) && !(S1.equals(S2))){
      System.out.println("Yes");
    }else if(S1.equals(S4) && S2.equals(S3) && !(S1.equals(S2))){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}