import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		String line[] = sc.nextLine().split("");
		sc.close();
		boolean isFifty = true;

		String char1 = null,char2 = null;
		int charCnt1 = 0,charCnt2 = 0;

		for(String s : line) {
			if(char1 == null || char1.equals(s)) {
				char1 = s;
				charCnt1++;
			}else if(char2 == null || char2.equals(s)) {
				char2 = s;
				charCnt2++;
			}else {
				isFifty = false;
				break;
			}

			if(charCnt1 > 2 || charCnt2> 2) {
				isFifty = false;
				break;
			}
		}

		System.out.println(isFifty ? "Yes" : "No");
	}
} 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().split("");
		sc.close();
		boolean isFifty = true;

		String char1 = null,char2 = null;
		int charCnt1 = 0,charCnt2 = 0;

		for(String s : line) {
			if(char1 == null || char1.equals(s)) {
				char1 = s;
				charCnt1++;
			}else if(char2 == null || char2.equals(s)) {
				char2 = s;
				charCnt2++;
			}else {
				isFifty = false;
				break;
			}

			if(charCnt1 > 2 || charCnt2> 2) {
				isFifty = false;
				break;
			}
		}

		System.out.println(isFifty ? "Yes" : "No");
	}
} Main public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		String line[] = sc.nextLine().split("");
		sc.close();
		boolean isFifty = true;

		String char1 = null,char2 = null;
		int charCnt1 = 0,charCnt2 = 0;

		for(String s : line) {
			if(char1 == null || char1.equals(s)) {
				char1 = s;
				charCnt1++;
			}else if(char2 == null || char2.equals(s)) {
				char2 = s;
				charCnt2++;
			}else {
				isFifty = false;
				break;
			}

			if(charCnt1 > 2 || charCnt2> 2) {
				isFifty = false;
				break;
			}
		}

		System.out.println(isFifty ? "Yes" : "No");
	} main {

		Scanner sc = new Scanner(System.in);

		String line[] = sc.nextLine().split("");
		sc.close();
		boolean isFifty = true;

		String char1 = null,char2 = null;
		int charCnt1 = 0,charCnt2 = 0;

		for(String s : line) {
			if(char1 == null || char1.equals(s)) {
				char1 = s;
				charCnt1++;
			}else if(char2 == null || char2.equals(s)) {
				char2 = s;
				charCnt2++;
			}else {
				isFifty = false;
				break;
			}

			if(charCnt1 > 2 || charCnt2> 2) {
				isFifty = false;
				break;
			}
		}

		System.out.println(isFifty ? "Yes" : "No");
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String line[] = sc.nextLine().split(""); line sc.nextLine().split("") sc.nextLine().split sc.nextLine() sc.nextLine sc "" sc.close() sc.close sc boolean isFifty = true; isFifty true String char1 = null char1 null char2 = null; char2 null int charCnt1 = 0 charCnt1 0 charCnt2 = 0; charCnt2 0 for(String s : line) {
			if(char1 == null || char1.equals(s)) {
				char1 = s;
				charCnt1++;
			}else if(char2 == null || char2.equals(s)) {
				char2 = s;
				charCnt2++;
			}else {
				isFifty = false;
				break;
			}

			if(charCnt1 > 2 || charCnt2> 2) {
				isFifty = false;
				break;
			}
		} String s line {
			if(char1 == null || char1.equals(s)) {
				char1 = s;
				charCnt1++;
			}else if(char2 == null || char2.equals(s)) {
				char2 = s;
				charCnt2++;
			}else {
				isFifty = false;
				break;
			}

			if(charCnt1 > 2 || charCnt2> 2) {
				isFifty = false;
				break;
			}
		} {
			if(char1 == null || char1.equals(s)) {
				char1 = s;
				charCnt1++;
			}else if(char2 == null || char2.equals(s)) {
				char2 = s;
				charCnt2++;
			}else {
				isFifty = false;
				break;
			}

			if(charCnt1 > 2 || charCnt2> 2) {
				isFifty = false;
				break;
			}
		} if(char1 == null || char1.equals(s)) {
				char1 = s;
				charCnt1++;
			}else if(char2 == null || char2.equals(s)) {
				char2 = s;
				charCnt2++;
			}else {
				isFifty = false;
				break;
			} char1 == null || char1.equals(s) char1 == null char1 null char1.equals(s) char1.equals char1 s {
				char1 = s;
				charCnt1++;
			} char1 = s char1 s charCnt1++ charCnt1 if(char2 == null || char2.equals(s)) {
				char2 = s;
				charCnt2++;
			}else {
				isFifty = false;
				break;
			} char2 == null || char2.equals(s) char2 == null char2 null char2.equals(s) char2.equals char2 s {
				char2 = s;
				charCnt2++;
			} char2 = s char2 s charCnt2++ charCnt2 {
				isFifty = false;
				break;
			} isFifty = false isFifty false break; if(charCnt1 > 2 || charCnt2> 2) {
				isFifty = false;
				break;
			} charCnt1 > 2 || charCnt2> 2 charCnt1 > 2 charCnt1 2 charCnt2> 2 charCnt2 2 {
				isFifty = false;
				break;
			} isFifty = false isFifty false break; System.out.println(isFifty ? "Yes" : "No") System.out.println System.out System System.out isFifty ? "Yes" : "No" isFifty "Yes" "No" String args[] args public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		String line[] = sc.nextLine().split("");
		sc.close();
		boolean isFifty = true;

		String char1 = null,char2 = null;
		int charCnt1 = 0,charCnt2 = 0;

		for(String s : line) {
			if(char1 == null || char1.equals(s)) {
				char1 = s;
				charCnt1++;
			}else if(char2 == null || char2.equals(s)) {
				char2 = s;
				charCnt2++;
			}else {
				isFifty = false;
				break;
			}

			if(charCnt1 > 2 || charCnt2> 2) {
				isFifty = false;
				break;
			}
		}

		System.out.println(isFifty ? "Yes" : "No");
	}
} public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		String line[] = sc.nextLine().split("");
		sc.close();
		boolean isFifty = true;

		String char1 = null,char2 = null;
		int charCnt1 = 0,charCnt2 = 0;

		for(String s : line) {
			if(char1 == null || char1.equals(s)) {
				char1 = s;
				charCnt1++;
			}else if(char2 == null || char2.equals(s)) {
				char2 = s;
				charCnt2++;
			}else {
				isFifty = false;
				break;
			}

			if(charCnt1 > 2 || charCnt2> 2) {
				isFifty = false;
				break;
			}
		}

		System.out.println(isFifty ? "Yes" : "No");
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		String line[] = sc.nextLine().split("");
		sc.close();
		boolean isFifty = true;

		String char1 = null,char2 = null;
		int charCnt1 = 0,charCnt2 = 0;

		for(String s : line) {
			if(char1 == null || char1.equals(s)) {
				char1 = s;
				charCnt1++;
			}else if(char2 == null || char2.equals(s)) {
				char2 = s;
				charCnt2++;
			}else {
				isFifty = false;
				break;
			}

			if(charCnt1 > 2 || charCnt2> 2) {
				isFifty = false;
				break;
			}
		}

		System.out.println(isFifty ? "Yes" : "No");
	}
}
