import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		
		String s = sc.next();
        String t = "No";
        if(s.charAt(0)==s.charAt(1))
        {if(s.charAt(2)==s.charAt(3) && s.charAt(0)!=s.charAt(2)){t = "Yes";}}
		 if(s.charAt(0)==s.charAt(2))
        {if(s.charAt(1)==s.charAt(3) && s.charAt(0)!=s.charAt(1)){t = "Yes";}}
         if(s.charAt(0)==s.charAt(3))
        {if(s.charAt(1)==s.charAt(2) && s.charAt(0)!=s.charAt(1)){t = "Yes";}}  
            System.out.println(t);
	}
} 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 t = "No";
        if(s.charAt(0)==s.charAt(1))
        {if(s.charAt(2)==s.charAt(3) && s.charAt(0)!=s.charAt(2)){t = "Yes";}}
		 if(s.charAt(0)==s.charAt(2))
        {if(s.charAt(1)==s.charAt(3) && s.charAt(0)!=s.charAt(1)){t = "Yes";}}
         if(s.charAt(0)==s.charAt(3))
        {if(s.charAt(1)==s.charAt(2) && s.charAt(0)!=s.charAt(1)){t = "Yes";}}  
            System.out.println(t);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		
		String s = sc.next();
        String t = "No";
        if(s.charAt(0)==s.charAt(1))
        {if(s.charAt(2)==s.charAt(3) && s.charAt(0)!=s.charAt(2)){t = "Yes";}}
		 if(s.charAt(0)==s.charAt(2))
        {if(s.charAt(1)==s.charAt(3) && s.charAt(0)!=s.charAt(1)){t = "Yes";}}
         if(s.charAt(0)==s.charAt(3))
        {if(s.charAt(1)==s.charAt(2) && s.charAt(0)!=s.charAt(1)){t = "Yes";}}  
            System.out.println(t);
	} main {
		Scanner sc = new Scanner(System.in);		
		String s = sc.next();
        String t = "No";
        if(s.charAt(0)==s.charAt(1))
        {if(s.charAt(2)==s.charAt(3) && s.charAt(0)!=s.charAt(2)){t = "Yes";}}
		 if(s.charAt(0)==s.charAt(2))
        {if(s.charAt(1)==s.charAt(3) && s.charAt(0)!=s.charAt(1)){t = "Yes";}}
         if(s.charAt(0)==s.charAt(3))
        {if(s.charAt(1)==s.charAt(2) && s.charAt(0)!=s.charAt(1)){t = "Yes";}}  
            System.out.println(t);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc String t = "No"; t "No" if(s.charAt(0)==s.charAt(1))
        {if(s.charAt(2)==s.charAt(3) && s.charAt(0)!=s.charAt(2)){t = "Yes";}} s.charAt(0)==s.charAt(1) s.charAt(0) s.charAt s 0 s.charAt(1) s.charAt s 1 {if(s.charAt(2)==s.charAt(3) && s.charAt(0)!=s.charAt(2)){t = "Yes";}} if(s.charAt(2)==s.charAt(3) && s.charAt(0)!=s.charAt(2)){t = "Yes";} s.charAt(2)==s.charAt(3) && s.charAt(0)!=s.charAt(2) s.charAt(2)==s.charAt(3) s.charAt(2) s.charAt s 2 s.charAt(3) s.charAt s 3 s.charAt(0)!=s.charAt(2) s.charAt(0) s.charAt s 0 s.charAt(2) s.charAt s 2 {t = "Yes";} t = "Yes" t "Yes" if(s.charAt(0)==s.charAt(2))
        {if(s.charAt(1)==s.charAt(3) && s.charAt(0)!=s.charAt(1)){t = "Yes";}} s.charAt(0)==s.charAt(2) s.charAt(0) s.charAt s 0 s.charAt(2) s.charAt s 2 {if(s.charAt(1)==s.charAt(3) && s.charAt(0)!=s.charAt(1)){t = "Yes";}} if(s.charAt(1)==s.charAt(3) && s.charAt(0)!=s.charAt(1)){t = "Yes";} s.charAt(1)==s.charAt(3) && s.charAt(0)!=s.charAt(1) s.charAt(1)==s.charAt(3) s.charAt(1) s.charAt s 1 s.charAt(3) s.charAt s 3 s.charAt(0)!=s.charAt(1) s.charAt(0) s.charAt s 0 s.charAt(1) s.charAt s 1 {t = "Yes";} t = "Yes" t "Yes" if(s.charAt(0)==s.charAt(3))
        {if(s.charAt(1)==s.charAt(2) && s.charAt(0)!=s.charAt(1)){t = "Yes";}} s.charAt(0)==s.charAt(3) s.charAt(0) s.charAt s 0 s.charAt(3) s.charAt s 3 {if(s.charAt(1)==s.charAt(2) && s.charAt(0)!=s.charAt(1)){t = "Yes";}} if(s.charAt(1)==s.charAt(2) && s.charAt(0)!=s.charAt(1)){t = "Yes";} s.charAt(1)==s.charAt(2) && s.charAt(0)!=s.charAt(1) s.charAt(1)==s.charAt(2) s.charAt(1) s.charAt s 1 s.charAt(2) s.charAt s 2 s.charAt(0)!=s.charAt(1) s.charAt(0) s.charAt s 0 s.charAt(1) s.charAt s 1 {t = "Yes";} t = "Yes" t "Yes" System.out.println(t) System.out.println System.out System System.out t String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		
		String s = sc.next();
        String t = "No";
        if(s.charAt(0)==s.charAt(1))
        {if(s.charAt(2)==s.charAt(3) && s.charAt(0)!=s.charAt(2)){t = "Yes";}}
		 if(s.charAt(0)==s.charAt(2))
        {if(s.charAt(1)==s.charAt(3) && s.charAt(0)!=s.charAt(1)){t = "Yes";}}
         if(s.charAt(0)==s.charAt(3))
        {if(s.charAt(1)==s.charAt(2) && s.charAt(0)!=s.charAt(1)){t = "Yes";}}  
            System.out.println(t);
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		
		String s = sc.next();
        String t = "No";
        if(s.charAt(0)==s.charAt(1))
        {if(s.charAt(2)==s.charAt(3) && s.charAt(0)!=s.charAt(2)){t = "Yes";}}
		 if(s.charAt(0)==s.charAt(2))
        {if(s.charAt(1)==s.charAt(3) && s.charAt(0)!=s.charAt(1)){t = "Yes";}}
         if(s.charAt(0)==s.charAt(3))
        {if(s.charAt(1)==s.charAt(2) && s.charAt(0)!=s.charAt(1)){t = "Yes";}}  
            System.out.println(t);
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		
		String s = sc.next();
        String t = "No";
        if(s.charAt(0)==s.charAt(1))
        {if(s.charAt(2)==s.charAt(3) && s.charAt(0)!=s.charAt(2)){t = "Yes";}}
		 if(s.charAt(0)==s.charAt(2))
        {if(s.charAt(1)==s.charAt(3) && s.charAt(0)!=s.charAt(1)){t = "Yes";}}
         if(s.charAt(0)==s.charAt(3))
        {if(s.charAt(1)==s.charAt(2) && s.charAt(0)!=s.charAt(1)){t = "Yes";}}  
            System.out.println(t);
	}
}
