import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main { 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		
		HashMap<Character,Integer> resultMap = new HashMap();
		for(int i = 0;i<line.length();i++) {
			Character tmp = line.charAt(i);
			if(resultMap.containsKey(tmp)) {
				resultMap.put(tmp, resultMap.get(tmp)+1);
			}else {
				resultMap.put(tmp, 0);
			}
		}
		
		String strResult = "No";

		if(resultMap.size() == 2) {
			 for(Integer t:resultMap.values()) {
				 if(resultMap.containsValue(t)) {
					 strResult = "Yes";
				 }
			 }
		}
		System.out.println(strResult);
		
	}
} import java.util.ArrayList; ArrayList java.util import java.util.HashMap; HashMap java.util import java.util.Scanner; Scanner java.util public class Main { 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		
		HashMap<Character,Integer> resultMap = new HashMap();
		for(int i = 0;i<line.length();i++) {
			Character tmp = line.charAt(i);
			if(resultMap.containsKey(tmp)) {
				resultMap.put(tmp, resultMap.get(tmp)+1);
			}else {
				resultMap.put(tmp, 0);
			}
		}
		
		String strResult = "No";

		if(resultMap.size() == 2) {
			 for(Integer t:resultMap.values()) {
				 if(resultMap.containsValue(t)) {
					 strResult = "Yes";
				 }
			 }
		}
		System.out.println(strResult);
		
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		
		HashMap<Character,Integer> resultMap = new HashMap();
		for(int i = 0;i<line.length();i++) {
			Character tmp = line.charAt(i);
			if(resultMap.containsKey(tmp)) {
				resultMap.put(tmp, resultMap.get(tmp)+1);
			}else {
				resultMap.put(tmp, 0);
			}
		}
		
		String strResult = "No";

		if(resultMap.size() == 2) {
			 for(Integer t:resultMap.values()) {
				 if(resultMap.containsValue(t)) {
					 strResult = "Yes";
				 }
			 }
		}
		System.out.println(strResult);
		
	} main {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		
		HashMap<Character,Integer> resultMap = new HashMap();
		for(int i = 0;i<line.length();i++) {
			Character tmp = line.charAt(i);
			if(resultMap.containsKey(tmp)) {
				resultMap.put(tmp, resultMap.get(tmp)+1);
			}else {
				resultMap.put(tmp, 0);
			}
		}
		
		String strResult = "No";

		if(resultMap.size() == 2) {
			 for(Integer t:resultMap.values()) {
				 if(resultMap.containsValue(t)) {
					 strResult = "Yes";
				 }
			 }
		}
		System.out.println(strResult);
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc HashMap<Character,Integer> resultMap = new HashMap(); resultMap new HashMap() for(int i = 0;i<line.length();i++) {
			Character tmp = line.charAt(i);
			if(resultMap.containsKey(tmp)) {
				resultMap.put(tmp, resultMap.get(tmp)+1);
			}else {
				resultMap.put(tmp, 0);
			}
		} int i = 0; int i = 0; i 0 i<line.length() i line.length() line.length line i++ i++ i {
			Character tmp = line.charAt(i);
			if(resultMap.containsKey(tmp)) {
				resultMap.put(tmp, resultMap.get(tmp)+1);
			}else {
				resultMap.put(tmp, 0);
			}
		} {
			Character tmp = line.charAt(i);
			if(resultMap.containsKey(tmp)) {
				resultMap.put(tmp, resultMap.get(tmp)+1);
			}else {
				resultMap.put(tmp, 0);
			}
		} Character tmp = line.charAt(i); tmp line.charAt(i) line.charAt line i if(resultMap.containsKey(tmp)) {
				resultMap.put(tmp, resultMap.get(tmp)+1);
			}else {
				resultMap.put(tmp, 0);
			} resultMap.containsKey(tmp) resultMap.containsKey resultMap tmp {
				resultMap.put(tmp, resultMap.get(tmp)+1);
			} resultMap.put(tmp, resultMap.get(tmp)+1) resultMap.put resultMap tmp resultMap.get(tmp)+1 resultMap.get(tmp) resultMap.get resultMap tmp 1 {
				resultMap.put(tmp, 0);
			} resultMap.put(tmp, 0) resultMap.put resultMap tmp 0 String strResult = "No"; strResult "No" if(resultMap.size() == 2) {
			 for(Integer t:resultMap.values()) {
				 if(resultMap.containsValue(t)) {
					 strResult = "Yes";
				 }
			 }
		} resultMap.size() == 2 resultMap.size() resultMap.size resultMap 2 {
			 for(Integer t:resultMap.values()) {
				 if(resultMap.containsValue(t)) {
					 strResult = "Yes";
				 }
			 }
		} for(Integer t:resultMap.values()) {
				 if(resultMap.containsValue(t)) {
					 strResult = "Yes";
				 }
			 } Integer t resultMap.values() resultMap.values resultMap {
				 if(resultMap.containsValue(t)) {
					 strResult = "Yes";
				 }
			 } {
				 if(resultMap.containsValue(t)) {
					 strResult = "Yes";
				 }
			 } if(resultMap.containsValue(t)) {
					 strResult = "Yes";
				 } resultMap.containsValue(t) resultMap.containsValue resultMap t {
					 strResult = "Yes";
				 } strResult = "Yes" strResult "Yes" System.out.println(strResult) System.out.println System.out System System.out strResult String[] args args public class Main { 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		
		HashMap<Character,Integer> resultMap = new HashMap();
		for(int i = 0;i<line.length();i++) {
			Character tmp = line.charAt(i);
			if(resultMap.containsKey(tmp)) {
				resultMap.put(tmp, resultMap.get(tmp)+1);
			}else {
				resultMap.put(tmp, 0);
			}
		}
		
		String strResult = "No";

		if(resultMap.size() == 2) {
			 for(Integer t:resultMap.values()) {
				 if(resultMap.containsValue(t)) {
					 strResult = "Yes";
				 }
			 }
		}
		System.out.println(strResult);
		
	}
} public class Main { 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		
		HashMap<Character,Integer> resultMap = new HashMap();
		for(int i = 0;i<line.length();i++) {
			Character tmp = line.charAt(i);
			if(resultMap.containsKey(tmp)) {
				resultMap.put(tmp, resultMap.get(tmp)+1);
			}else {
				resultMap.put(tmp, 0);
			}
		}
		
		String strResult = "No";

		if(resultMap.size() == 2) {
			 for(Integer t:resultMap.values()) {
				 if(resultMap.containsValue(t)) {
					 strResult = "Yes";
				 }
			 }
		}
		System.out.println(strResult);
		
	}
} Main
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main { 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		
		HashMap<Character,Integer> resultMap = new HashMap();
		for(int i = 0;i<line.length();i++) {
			Character tmp = line.charAt(i);
			if(resultMap.containsKey(tmp)) {
				resultMap.put(tmp, resultMap.get(tmp)+1);
			}else {
				resultMap.put(tmp, 0);
			}
		}
		
		String strResult = "No";

		if(resultMap.size() == 2) {
			 for(Integer t:resultMap.values()) {
				 if(resultMap.containsValue(t)) {
					 strResult = "Yes";
				 }
			 }
		}
		System.out.println(strResult);
		
	}
}