import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//文字列を宣言して読み込む
		String A = sc.next();
		String ans = "No";
		if(A.charAt(0)==A.charAt(1)){
			if((A.charAt(2)==A.charAt(3))&&(A.charAt(1)!=A.charAt(2))){			
				ans="Yes";
				System.out.println(ans);
				}
			}
	if(A.charAt(0)!=A.charAt(1)){
		if((A.charAt(0)==A.charAt(3))&&(A.charAt(1)==A.charAt(2))||(A.charAt(0)==A.charAt(2))&&(A.charAt(1)==A.charAt(3))){
			ans="Yes";
			System.out.println(ans);		
		}
	}
	if(ans=="No"){
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 A = sc.next();
		String ans = "No";
		if(A.charAt(0)==A.charAt(1)){
			if((A.charAt(2)==A.charAt(3))&&(A.charAt(1)!=A.charAt(2))){			
				ans="Yes";
				System.out.println(ans);
				}
			}
	if(A.charAt(0)!=A.charAt(1)){
		if((A.charAt(0)==A.charAt(3))&&(A.charAt(1)==A.charAt(2))||(A.charAt(0)==A.charAt(2))&&(A.charAt(1)==A.charAt(3))){
			ans="Yes";
			System.out.println(ans);		
		}
	}
	if(ans=="No"){
System.out.println(ans);
	}
	
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//文字列を宣言して読み込む
		String A = sc.next();
		String ans = "No";
		if(A.charAt(0)==A.charAt(1)){
			if((A.charAt(2)==A.charAt(3))&&(A.charAt(1)!=A.charAt(2))){			
				ans="Yes";
				System.out.println(ans);
				}
			}
	if(A.charAt(0)!=A.charAt(1)){
		if((A.charAt(0)==A.charAt(3))&&(A.charAt(1)==A.charAt(2))||(A.charAt(0)==A.charAt(2))&&(A.charAt(1)==A.charAt(3))){
			ans="Yes";
			System.out.println(ans);		
		}
	}
	if(ans=="No"){
System.out.println(ans);
	}
	
	} main {
		Scanner sc = new Scanner(System.in);
		//文字列を宣言して読み込む
		String A = sc.next();
		String ans = "No";
		if(A.charAt(0)==A.charAt(1)){
			if((A.charAt(2)==A.charAt(3))&&(A.charAt(1)!=A.charAt(2))){			
				ans="Yes";
				System.out.println(ans);
				}
			}
	if(A.charAt(0)!=A.charAt(1)){
		if((A.charAt(0)==A.charAt(3))&&(A.charAt(1)==A.charAt(2))||(A.charAt(0)==A.charAt(2))&&(A.charAt(1)==A.charAt(3))){
			ans="Yes";
			System.out.println(ans);		
		}
	}
	if(ans=="No"){
System.out.println(ans);
	}
	
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String A = sc.next(); A sc.next() sc.next sc String ans = "No"; ans "No" if(A.charAt(0)==A.charAt(1)){
			if((A.charAt(2)==A.charAt(3))&&(A.charAt(1)!=A.charAt(2))){			
				ans="Yes";
				System.out.println(ans);
				}
			} A.charAt(0)==A.charAt(1) A.charAt(0) A.charAt A 0 A.charAt(1) A.charAt A 1 {
			if((A.charAt(2)==A.charAt(3))&&(A.charAt(1)!=A.charAt(2))){			
				ans="Yes";
				System.out.println(ans);
				}
			} if((A.charAt(2)==A.charAt(3))&&(A.charAt(1)!=A.charAt(2))){			
				ans="Yes";
				System.out.println(ans);
				} (A.charAt(2)==A.charAt(3))&&(A.charAt(1)!=A.charAt(2)) (A.charAt(2)==A.charAt(3)) A.charAt(2) A.charAt A 2 A.charAt(3) A.charAt A 3 (A.charAt(1)!=A.charAt(2)) A.charAt(1) A.charAt A 1 A.charAt(2) A.charAt A 2 {			
				ans="Yes";
				System.out.println(ans);
				} ans="Yes" ans "Yes" System.out.println(ans) System.out.println System.out System System.out ans if(A.charAt(0)!=A.charAt(1)){
		if((A.charAt(0)==A.charAt(3))&&(A.charAt(1)==A.charAt(2))||(A.charAt(0)==A.charAt(2))&&(A.charAt(1)==A.charAt(3))){
			ans="Yes";
			System.out.println(ans);		
		}
	} A.charAt(0)!=A.charAt(1) A.charAt(0) A.charAt A 0 A.charAt(1) A.charAt A 1 {
		if((A.charAt(0)==A.charAt(3))&&(A.charAt(1)==A.charAt(2))||(A.charAt(0)==A.charAt(2))&&(A.charAt(1)==A.charAt(3))){
			ans="Yes";
			System.out.println(ans);		
		}
	} if((A.charAt(0)==A.charAt(3))&&(A.charAt(1)==A.charAt(2))||(A.charAt(0)==A.charAt(2))&&(A.charAt(1)==A.charAt(3))){
			ans="Yes";
			System.out.println(ans);		
		} (A.charAt(0)==A.charAt(3))&&(A.charAt(1)==A.charAt(2))||(A.charAt(0)==A.charAt(2))&&(A.charAt(1)==A.charAt(3)) (A.charAt(0)==A.charAt(3))&&(A.charAt(1)==A.charAt(2)) (A.charAt(0)==A.charAt(3)) A.charAt(0) A.charAt A 0 A.charAt(3) A.charAt A 3 (A.charAt(1)==A.charAt(2)) A.charAt(1) A.charAt A 1 A.charAt(2) A.charAt A 2 (A.charAt(0)==A.charAt(2))&&(A.charAt(1)==A.charAt(3)) (A.charAt(0)==A.charAt(2)) A.charAt(0) A.charAt A 0 A.charAt(2) A.charAt A 2 (A.charAt(1)==A.charAt(3)) A.charAt(1) A.charAt A 1 A.charAt(3) A.charAt A 3 {
			ans="Yes";
			System.out.println(ans);		
		} ans="Yes" ans "Yes" System.out.println(ans) System.out.println System.out System System.out ans if(ans=="No"){
System.out.println(ans);
	} ans=="No" ans "No" {
System.out.println(ans);
	} 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 A = sc.next();
		String ans = "No";
		if(A.charAt(0)==A.charAt(1)){
			if((A.charAt(2)==A.charAt(3))&&(A.charAt(1)!=A.charAt(2))){			
				ans="Yes";
				System.out.println(ans);
				}
			}
	if(A.charAt(0)!=A.charAt(1)){
		if((A.charAt(0)==A.charAt(3))&&(A.charAt(1)==A.charAt(2))||(A.charAt(0)==A.charAt(2))&&(A.charAt(1)==A.charAt(3))){
			ans="Yes";
			System.out.println(ans);		
		}
	}
	if(ans=="No"){
System.out.println(ans);
	}
	
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//文字列を宣言して読み込む
		String A = sc.next();
		String ans = "No";
		if(A.charAt(0)==A.charAt(1)){
			if((A.charAt(2)==A.charAt(3))&&(A.charAt(1)!=A.charAt(2))){			
				ans="Yes";
				System.out.println(ans);
				}
			}
	if(A.charAt(0)!=A.charAt(1)){
		if((A.charAt(0)==A.charAt(3))&&(A.charAt(1)==A.charAt(2))||(A.charAt(0)==A.charAt(2))&&(A.charAt(1)==A.charAt(3))){
			ans="Yes";
			System.out.println(ans);		
		}
	}
	if(ans=="No"){
System.out.println(ans);
	}
	
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//文字列を宣言して読み込む
		String A = sc.next();
		String ans = "No";
		if(A.charAt(0)==A.charAt(1)){
			if((A.charAt(2)==A.charAt(3))&&(A.charAt(1)!=A.charAt(2))){			
				ans="Yes";
				System.out.println(ans);
				}
			}
	if(A.charAt(0)!=A.charAt(1)){
		if((A.charAt(0)==A.charAt(3))&&(A.charAt(1)==A.charAt(2))||(A.charAt(0)==A.charAt(2))&&(A.charAt(1)==A.charAt(3))){
			ans="Yes";
			System.out.println(ans);		
		}
	}
	if(ans=="No"){
System.out.println(ans);
	}
	
	}
}