import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		HashSet<String> h = new HashSet<String>();

		String[] s = sc.next().split("");
		String ss = String.join("", s);

		for(int i = 0; i < 4; i++) {
			h.add(s[i]);
		}

		System.out.println(h.size() == 2 && ss.replace(ss.substring(0, 1), "").length() == 2 ? "Yes" : "No");
	}
} import java.util.HashSet; HashSet java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		HashSet<String> h = new HashSet<String>();

		String[] s = sc.next().split("");
		String ss = String.join("", s);

		for(int i = 0; i < 4; i++) {
			h.add(s[i]);
		}

		System.out.println(h.size() == 2 && ss.replace(ss.substring(0, 1), "").length() == 2 ? "Yes" : "No");
	}
} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		HashSet<String> h = new HashSet<String>();

		String[] s = sc.next().split("");
		String ss = String.join("", s);

		for(int i = 0; i < 4; i++) {
			h.add(s[i]);
		}

		System.out.println(h.size() == 2 && ss.replace(ss.substring(0, 1), "").length() == 2 ? "Yes" : "No");
	} main {

		Scanner sc = new Scanner(System.in);
		HashSet<String> h = new HashSet<String>();

		String[] s = sc.next().split("");
		String ss = String.join("", s);

		for(int i = 0; i < 4; i++) {
			h.add(s[i]);
		}

		System.out.println(h.size() == 2 && ss.replace(ss.substring(0, 1), "").length() == 2 ? "Yes" : "No");
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) HashSet<String> h = new HashSet<String>(); h new HashSet<String>() String[] s = sc.next().split(""); s sc.next().split("") sc.next().split sc.next() sc.next sc "" String ss = String.join("", s); ss String.join("", s) String.join String "" s for(int i = 0; i < 4; i++) {
			h.add(s[i]);
		} int i = 0; int i = 0; i 0 i < 4 i 4 i++ i++ i {
			h.add(s[i]);
		} {
			h.add(s[i]);
		} h.add(s[i]) h.add h s[i] s i System.out.println(h.size() == 2 && ss.replace(ss.substring(0, 1), "").length() == 2 ? "Yes" : "No") System.out.println System.out System System.out h.size() == 2 && ss.replace(ss.substring(0, 1), "").length() == 2 ? "Yes" : "No" h.size() == 2 && ss.replace(ss.substring(0, 1), "").length() == 2 h.size() == 2 h.size() h.size h 2 ss.replace(ss.substring(0, 1), "").length() == 2 ss.replace(ss.substring(0, 1), "").length() ss.replace(ss.substring(0, 1), "").length ss.replace(ss.substring(0, 1), "") ss.replace ss ss.substring(0, 1) ss.substring ss 0 1 "" 2 "Yes" "No" String[] args args public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		HashSet<String> h = new HashSet<String>();

		String[] s = sc.next().split("");
		String ss = String.join("", s);

		for(int i = 0; i < 4; i++) {
			h.add(s[i]);
		}

		System.out.println(h.size() == 2 && ss.replace(ss.substring(0, 1), "").length() == 2 ? "Yes" : "No");
	}
} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		HashSet<String> h = new HashSet<String>();

		String[] s = sc.next().split("");
		String ss = String.join("", s);

		for(int i = 0; i < 4; i++) {
			h.add(s[i]);
		}

		System.out.println(h.size() == 2 && ss.replace(ss.substring(0, 1), "").length() == 2 ? "Yes" : "No");
	}
} Main
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		HashSet<String> h = new HashSet<String>();

		String[] s = sc.next().split("");
		String ss = String.join("", s);

		for(int i = 0; i < 4; i++) {
			h.add(s[i]);
		}

		System.out.println(h.size() == 2 && ss.replace(ss.substring(0, 1), "").length() == 2 ? "Yes" : "No");
	}
}