import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char h[] = new char[4];
    for(int i=0;i<4;i++){
      h[i] = S.charAt(i);
    }
    String answer = "No";
    Arrays.sort(h);
    if(h[0]==h[1]&&h[1]!=h[2]&&h[2]==h[3]){
      answer = "Yes";
    }
    System.out.println(answer);
    
  }
  
  //最大公約数・最小公倍数（セットで使う）
static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
static int lcm (int a, int b) {return a*b/gcd(a,b);}


//素数判定
static boolean isPrime (int n) {
	if (n==2) return true;
	if (n<2 || n%2==0) return false;
	double d = Math.sqrt(n);
	for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
	return true;
}


//倍数判定（10進数以外のときに有用）
static boolean isMultiple (String s, int base, int m) {
	int temp = 0;
	for (int i=0; i<s.length(); i++) {
		temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
	}
	if (temp==0) {return true;}
	return false;
}


//階乗
static long factorial (int i) {
	if (i==1) {return 1;}
	else {return i*factorial(i-1);}
}


//進数変換
static String toNbase (String sm, int m, int n) {
	return Long.toString(Long.parseLong(sm,m),n);
}
  
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char h[] = new char[4];
    for(int i=0;i<4;i++){
      h[i] = S.charAt(i);
    }
    String answer = "No";
    Arrays.sort(h);
    if(h[0]==h[1]&&h[1]!=h[2]&&h[2]==h[3]){
      answer = "Yes";
    }
    System.out.println(answer);
    
  }
  
  //最大公約数・最小公倍数（セットで使う）
static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
static int lcm (int a, int b) {return a*b/gcd(a,b);}


//素数判定
static boolean isPrime (int n) {
	if (n==2) return true;
	if (n<2 || n%2==0) return false;
	double d = Math.sqrt(n);
	for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
	return true;
}


//倍数判定（10進数以外のときに有用）
static boolean isMultiple (String s, int base, int m) {
	int temp = 0;
	for (int i=0; i<s.length(); i++) {
		temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
	}
	if (temp==0) {return true;}
	return false;
}


//階乗
static long factorial (int i) {
	if (i==1) {return 1;}
	else {return i*factorial(i-1);}
}


//進数変換
static String toNbase (String sm, int m, int n) {
	return Long.toString(Long.parseLong(sm,m),n);
}
  
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char h[] = new char[4];
    for(int i=0;i<4;i++){
      h[i] = S.charAt(i);
    }
    String answer = "No";
    Arrays.sort(h);
    if(h[0]==h[1]&&h[1]!=h[2]&&h[2]==h[3]){
      answer = "Yes";
    }
    System.out.println(answer);
    
  } main {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char h[] = new char[4];
    for(int i=0;i<4;i++){
      h[i] = S.charAt(i);
    }
    String answer = "No";
    Arrays.sort(h);
    if(h[0]==h[1]&&h[1]!=h[2]&&h[2]==h[3]){
      answer = "Yes";
    }
    System.out.println(answer);
    
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc char h[] = new char[4]; h new char[4] 4 for(int i=0;i<4;i++){
      h[i] = S.charAt(i);
    } int i=0; int i=0; i 0 i<4 i 4 i++ i++ i {
      h[i] = S.charAt(i);
    } {
      h[i] = S.charAt(i);
    } h[i] = S.charAt(i) h[i] h i S.charAt(i) S.charAt S i String answer = "No"; answer "No" Arrays.sort(h) Arrays.sort Arrays h if(h[0]==h[1]&&h[1]!=h[2]&&h[2]==h[3]){
      answer = "Yes";
    } h[0]==h[1]&&h[1]!=h[2]&&h[2]==h[3] h[0]==h[1]&&h[1]!=h[2]&&h[2]==h[3] h[0]==h[1] h[0] h 0 h[1] h 1 h[1]!=h[2] h[1] h 1 h[2] h 2 h[2]==h[3] h[2] h 2 h[3] h 3 {
      answer = "Yes";
    } answer = "Yes" answer "Yes" System.out.println(answer) System.out.println System.out System System.out answer String[] args args //最大公約数・最小公倍数（セットで使う）
static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;} gcd {return b>0?gcd(b,a%b):a;} return b>0?gcd(b,a%b):a; b>0?gcd(b,a%b):a b>0 b 0 gcd(b,a%b) gcd b a%b a b a int a a int b b static int lcm (int a, int b) {return a*b/gcd(a,b);} lcm {return a*b/gcd(a,b);} return a*b/gcd(a,b); a*b/gcd(a,b) a*b a b gcd(a,b) gcd a b int a a int b b //素数判定
static boolean isPrime (int n) {
	if (n==2) return true;
	if (n<2 || n%2==0) return false;
	double d = Math.sqrt(n);
	for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
	return true;
} isPrime {
	if (n==2) return true;
	if (n<2 || n%2==0) return false;
	double d = Math.sqrt(n);
	for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
	return true;
} if (n==2) return true; n==2 n 2 return true; true if (n<2 || n%2==0) return false; n<2 || n%2==0 n<2 n 2 n%2==0 n%2 n 2 0 return false; false double d = Math.sqrt(n); d Math.sqrt(n) Math.sqrt Math n for (int i=3; i<=d; i+=2) if(n%i==0){return false;} int i=3; int i=3; i 3 i<=d i d i+=2 i+=2 i 2 if(n%i==0){return false;} if(n%i==0){return false;} n%i==0 n%i n i 0 {return false;} return false; false return true; true int n n //倍数判定（10進数以外のときに有用）
static boolean isMultiple (String s, int base, int m) {
	int temp = 0;
	for (int i=0; i<s.length(); i++) {
		temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
	}
	if (temp==0) {return true;}
	return false;
} isMultiple {
	int temp = 0;
	for (int i=0; i<s.length(); i++) {
		temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
	}
	if (temp==0) {return true;}
	return false;
} int temp = 0; temp 0 for (int i=0; i<s.length(); i++) {
		temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
	} int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
		temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
	} {
		temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
	} temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m temp (temp*base+Character.getNumericValue(s.charAt(i)))%m (temp*base+Character.getNumericValue(s.charAt(i))) temp*base temp base Character.getNumericValue(s.charAt(i)) Character.getNumericValue Character s.charAt(i) s.charAt s i m if (temp==0) {return true;} temp==0 temp 0 {return true;} return true; true return false; false String s s int base base int m m //階乗
static long factorial (int i) {
	if (i==1) {return 1;}
	else {return i*factorial(i-1);}
} factorial {
	if (i==1) {return 1;}
	else {return i*factorial(i-1);}
} if (i==1) {return 1;}
	else {return i*factorial(i-1);} i==1 i 1 {return 1;} return 1; 1 {return i*factorial(i-1);} return i*factorial(i-1); i*factorial(i-1) i factorial(i-1) factorial i-1 i 1 int i i //進数変換
static String toNbase (String sm, int m, int n) {
	return Long.toString(Long.parseLong(sm,m),n);
} toNbase {
	return Long.toString(Long.parseLong(sm,m),n);
} return Long.toString(Long.parseLong(sm,m),n); Long.toString(Long.parseLong(sm,m),n) Long.toString Long Long.parseLong(sm,m) Long.parseLong Long sm m n String sm sm int m m int n n public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char h[] = new char[4];
    for(int i=0;i<4;i++){
      h[i] = S.charAt(i);
    }
    String answer = "No";
    Arrays.sort(h);
    if(h[0]==h[1]&&h[1]!=h[2]&&h[2]==h[3]){
      answer = "Yes";
    }
    System.out.println(answer);
    
  }
  
  //最大公約数・最小公倍数（セットで使う）
static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
static int lcm (int a, int b) {return a*b/gcd(a,b);}


//素数判定
static boolean isPrime (int n) {
	if (n==2) return true;
	if (n<2 || n%2==0) return false;
	double d = Math.sqrt(n);
	for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
	return true;
}


//倍数判定（10進数以外のときに有用）
static boolean isMultiple (String s, int base, int m) {
	int temp = 0;
	for (int i=0; i<s.length(); i++) {
		temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
	}
	if (temp==0) {return true;}
	return false;
}


//階乗
static long factorial (int i) {
	if (i==1) {return 1;}
	else {return i*factorial(i-1);}
}


//進数変換
static String toNbase (String sm, int m, int n) {
	return Long.toString(Long.parseLong(sm,m),n);
}
  
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char h[] = new char[4];
    for(int i=0;i<4;i++){
      h[i] = S.charAt(i);
    }
    String answer = "No";
    Arrays.sort(h);
    if(h[0]==h[1]&&h[1]!=h[2]&&h[2]==h[3]){
      answer = "Yes";
    }
    System.out.println(answer);
    
  }
  
  //最大公約数・最小公倍数（セットで使う）
static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
static int lcm (int a, int b) {return a*b/gcd(a,b);}


//素数判定
static boolean isPrime (int n) {
	if (n==2) return true;
	if (n<2 || n%2==0) return false;
	double d = Math.sqrt(n);
	for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
	return true;
}


//倍数判定（10進数以外のときに有用）
static boolean isMultiple (String s, int base, int m) {
	int temp = 0;
	for (int i=0; i<s.length(); i++) {
		temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
	}
	if (temp==0) {return true;}
	return false;
}


//階乗
static long factorial (int i) {
	if (i==1) {return 1;}
	else {return i*factorial(i-1);}
}


//進数変換
static String toNbase (String sm, int m, int n) {
	return Long.toString(Long.parseLong(sm,m),n);
}
  
} Main
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char h[] = new char[4];
    for(int i=0;i<4;i++){
      h[i] = S.charAt(i);
    }
    String answer = "No";
    Arrays.sort(h);
    if(h[0]==h[1]&&h[1]!=h[2]&&h[2]==h[3]){
      answer = "Yes";
    }
    System.out.println(answer);
    
  }
  
  //最大公約数・最小公倍数（セットで使う）
static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
static int lcm (int a, int b) {return a*b/gcd(a,b);}


//素数判定
static boolean isPrime (int n) {
	if (n==2) return true;
	if (n<2 || n%2==0) return false;
	double d = Math.sqrt(n);
	for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
	return true;
}


//倍数判定（10進数以外のときに有用）
static boolean isMultiple (String s, int base, int m) {
	int temp = 0;
	for (int i=0; i<s.length(); i++) {
		temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
	}
	if (temp==0) {return true;}
	return false;
}


//階乗
static long factorial (int i) {
	if (i==1) {return 1;}
	else {return i*factorial(i-1);}
}


//進数変換
static String toNbase (String sm, int m, int n) {
	return Long.toString(Long.parseLong(sm,m),n);
}
  
}