import java.util.*;
import java.lang.*;
import java.io.*;

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

public class Main{
public static void main (String[] args){
	Scanner sc = new Scanner(System.in);
	String s = sc.next();
	String a = s.substring(0,1);
	String b = s.substring(1,2);
	String c = s.substring(2,3);
	String d = s.substring(3,4);
	if((a.equals(b) && !(a.equals(c)) && c.equals(d)) || (a.equals(c) && !(a.equals(b)) && b.equals(d)) ||(a.equals(d) && !(a.equals(b)) && b.equals(c))){
		System.out.println("Yes");
	}else{
		System.out.println("No");
	}
	
}
}
