import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.nextLine();
    List<String> arr = new ArrayList<String>();
    List<String> arr2 = new ArrayList<String>();
    int countx = 0;  
    int county = 0;  
    for(int i = 0; i < str.length(); i++) {
      String tmp = String.valueOf(str.charAt(i));
      arr2.add(tmp);
      if(arr.contains(tmp) == false){
        arr.add(tmp);
      }
    }
    if(arr.size() > 2){
      System.out.println("No");
      return;
    }
    String x = arr2.get(0);
    String y = arr2.get(1);
   
    for(int i = 0; i < str.length(); i++) {
      if(x.equals(String.valueOf(str.charAt(i)))){
      	countx++;
      }else{
        county++;
      }
    }
    if(countx != 2 || county != 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 str = sc.nextLine();
    List<String> arr = new ArrayList<String>();
    List<String> arr2 = new ArrayList<String>();
    int countx = 0;  
    int county = 0;  
    for(int i = 0; i < str.length(); i++) {
      String tmp = String.valueOf(str.charAt(i));
      arr2.add(tmp);
      if(arr.contains(tmp) == false){
        arr.add(tmp);
      }
    }
    if(arr.size() > 2){
      System.out.println("No");
      return;
    }
    String x = arr2.get(0);
    String y = arr2.get(1);
   
    for(int i = 0; i < str.length(); i++) {
      if(x.equals(String.valueOf(str.charAt(i)))){
      	countx++;
      }else{
        county++;
      }
    }
    if(countx != 2 || county != 2){     
		System.out.println("No");
      	return;
    }
	System.out.println("Yes");
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.nextLine();
    List<String> arr = new ArrayList<String>();
    List<String> arr2 = new ArrayList<String>();
    int countx = 0;  
    int county = 0;  
    for(int i = 0; i < str.length(); i++) {
      String tmp = String.valueOf(str.charAt(i));
      arr2.add(tmp);
      if(arr.contains(tmp) == false){
        arr.add(tmp);
      }
    }
    if(arr.size() > 2){
      System.out.println("No");
      return;
    }
    String x = arr2.get(0);
    String y = arr2.get(1);
   
    for(int i = 0; i < str.length(); i++) {
      if(x.equals(String.valueOf(str.charAt(i)))){
      	countx++;
      }else{
        county++;
      }
    }
    if(countx != 2 || county != 2){     
		System.out.println("No");
      	return;
    }
	System.out.println("Yes");
  } main {
    Scanner sc = new Scanner(System.in);
    String str = sc.nextLine();
    List<String> arr = new ArrayList<String>();
    List<String> arr2 = new ArrayList<String>();
    int countx = 0;  
    int county = 0;  
    for(int i = 0; i < str.length(); i++) {
      String tmp = String.valueOf(str.charAt(i));
      arr2.add(tmp);
      if(arr.contains(tmp) == false){
        arr.add(tmp);
      }
    }
    if(arr.size() > 2){
      System.out.println("No");
      return;
    }
    String x = arr2.get(0);
    String y = arr2.get(1);
   
    for(int i = 0; i < str.length(); i++) {
      if(x.equals(String.valueOf(str.charAt(i)))){
      	countx++;
      }else{
        county++;
      }
    }
    if(countx != 2 || county != 2){     
		System.out.println("No");
      	return;
    }
	System.out.println("Yes");
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.nextLine(); str sc.nextLine() sc.nextLine sc List<String> arr = new ArrayList<String>(); arr new ArrayList<String>() List<String> arr2 = new ArrayList<String>(); arr2 new ArrayList<String>() int countx = 0; countx 0 int county = 0; county 0 for(int i = 0; i < str.length(); i++) {
      String tmp = String.valueOf(str.charAt(i));
      arr2.add(tmp);
      if(arr.contains(tmp) == false){
        arr.add(tmp);
      }
    } int i = 0; int i = 0; i 0 i < str.length() i str.length() str.length str i++ i++ i {
      String tmp = String.valueOf(str.charAt(i));
      arr2.add(tmp);
      if(arr.contains(tmp) == false){
        arr.add(tmp);
      }
    } {
      String tmp = String.valueOf(str.charAt(i));
      arr2.add(tmp);
      if(arr.contains(tmp) == false){
        arr.add(tmp);
      }
    } String tmp = String.valueOf(str.charAt(i)); tmp String.valueOf(str.charAt(i)) String.valueOf String str.charAt(i) str.charAt str i arr2.add(tmp) arr2.add arr2 tmp if(arr.contains(tmp) == false){
        arr.add(tmp);
      } arr.contains(tmp) == false arr.contains(tmp) arr.contains arr tmp false {
        arr.add(tmp);
      } arr.add(tmp) arr.add arr tmp if(arr.size() > 2){
      System.out.println("No");
      return;
    } arr.size() > 2 arr.size() arr.size arr 2 {
      System.out.println("No");
      return;
    } System.out.println("No") System.out.println System.out System System.out "No" return; String x = arr2.get(0); x arr2.get(0) arr2.get arr2 0 String y = arr2.get(1); y arr2.get(1) arr2.get arr2 1 for(int i = 0; i < str.length(); i++) {
      if(x.equals(String.valueOf(str.charAt(i)))){
      	countx++;
      }else{
        county++;
      }
    } int i = 0; int i = 0; i 0 i < str.length() i str.length() str.length str i++ i++ i {
      if(x.equals(String.valueOf(str.charAt(i)))){
      	countx++;
      }else{
        county++;
      }
    } {
      if(x.equals(String.valueOf(str.charAt(i)))){
      	countx++;
      }else{
        county++;
      }
    } if(x.equals(String.valueOf(str.charAt(i)))){
      	countx++;
      }else{
        county++;
      } x.equals(String.valueOf(str.charAt(i))) x.equals x String.valueOf(str.charAt(i)) String.valueOf String str.charAt(i) str.charAt str i {
      	countx++;
      } countx++ countx {
        county++;
      } county++ county if(countx != 2 || county != 2){     
		System.out.println("No");
      	return;
    } countx != 2 || county != 2 countx != 2 countx 2 county != 2 county 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 str = sc.nextLine();
    List<String> arr = new ArrayList<String>();
    List<String> arr2 = new ArrayList<String>();
    int countx = 0;  
    int county = 0;  
    for(int i = 0; i < str.length(); i++) {
      String tmp = String.valueOf(str.charAt(i));
      arr2.add(tmp);
      if(arr.contains(tmp) == false){
        arr.add(tmp);
      }
    }
    if(arr.size() > 2){
      System.out.println("No");
      return;
    }
    String x = arr2.get(0);
    String y = arr2.get(1);
   
    for(int i = 0; i < str.length(); i++) {
      if(x.equals(String.valueOf(str.charAt(i)))){
      	countx++;
      }else{
        county++;
      }
    }
    if(countx != 2 || county != 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 str = sc.nextLine();
    List<String> arr = new ArrayList<String>();
    List<String> arr2 = new ArrayList<String>();
    int countx = 0;  
    int county = 0;  
    for(int i = 0; i < str.length(); i++) {
      String tmp = String.valueOf(str.charAt(i));
      arr2.add(tmp);
      if(arr.contains(tmp) == false){
        arr.add(tmp);
      }
    }
    if(arr.size() > 2){
      System.out.println("No");
      return;
    }
    String x = arr2.get(0);
    String y = arr2.get(1);
   
    for(int i = 0; i < str.length(); i++) {
      if(x.equals(String.valueOf(str.charAt(i)))){
      	countx++;
      }else{
        county++;
      }
    }
    if(countx != 2 || county != 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 str = sc.nextLine();
    List<String> arr = new ArrayList<String>();
    List<String> arr2 = new ArrayList<String>();
    int countx = 0;  
    int county = 0;  
    for(int i = 0; i < str.length(); i++) {
      String tmp = String.valueOf(str.charAt(i));
      arr2.add(tmp);
      if(arr.contains(tmp) == false){
        arr.add(tmp);
      }
    }
    if(arr.size() > 2){
      System.out.println("No");
      return;
    }
    String x = arr2.get(0);
    String y = arr2.get(1);
   
    for(int i = 0; i < str.length(); i++) {
      if(x.equals(String.valueOf(str.charAt(i)))){
      	countx++;
      }else{
        county++;
      }
    }
    if(countx != 2 || county != 2){     
		System.out.println("No");
      	return;
    }
	System.out.println("Yes");
  }
}
