import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args){

		Scanner sc=new Scanner(System.in);

		String[] str=(sc.next()).split("");

		sc.close();

		List<String> list=new ArrayList<String>();

		int cnt=0;

		for(int i=0;i<4;i++){
			if(list.contains(str[i])){
				cnt++;
			}else{
				list.add(str[i]);
			}
		}

		if(list.size()>2){
			System.out.println("No");
		}else{
			if(cnt==2){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}


	}
} import java.util.ArrayList; ArrayList java.util import java.util.List; List 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[] str=(sc.next()).split("");

		sc.close();

		List<String> list=new ArrayList<String>();

		int cnt=0;

		for(int i=0;i<4;i++){
			if(list.contains(str[i])){
				cnt++;
			}else{
				list.add(str[i]);
			}
		}

		if(list.size()>2){
			System.out.println("No");
		}else{
			if(cnt==2){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}


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

		Scanner sc=new Scanner(System.in);

		String[] str=(sc.next()).split("");

		sc.close();

		List<String> list=new ArrayList<String>();

		int cnt=0;

		for(int i=0;i<4;i++){
			if(list.contains(str[i])){
				cnt++;
			}else{
				list.add(str[i]);
			}
		}

		if(list.size()>2){
			System.out.println("No");
		}else{
			if(cnt==2){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}


	} main {

		Scanner sc=new Scanner(System.in);

		String[] str=(sc.next()).split("");

		sc.close();

		List<String> list=new ArrayList<String>();

		int cnt=0;

		for(int i=0;i<4;i++){
			if(list.contains(str[i])){
				cnt++;
			}else{
				list.add(str[i]);
			}
		}

		if(list.size()>2){
			System.out.println("No");
		}else{
			if(cnt==2){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}


	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String[] str=(sc.next()).split(""); str (sc.next()).split("") (sc.next()).split (sc.next()) sc.next sc "" sc.close() sc.close sc List<String> list=new ArrayList<String>(); list new ArrayList<String>() int cnt=0; cnt 0 for(int i=0;i<4;i++){
			if(list.contains(str[i])){
				cnt++;
			}else{
				list.add(str[i]);
			}
		} int i=0; int i=0; i 0 i<4 i 4 i++ i++ i {
			if(list.contains(str[i])){
				cnt++;
			}else{
				list.add(str[i]);
			}
		} {
			if(list.contains(str[i])){
				cnt++;
			}else{
				list.add(str[i]);
			}
		} if(list.contains(str[i])){
				cnt++;
			}else{
				list.add(str[i]);
			} list.contains(str[i]) list.contains list str[i] str i {
				cnt++;
			} cnt++ cnt {
				list.add(str[i]);
			} list.add(str[i]) list.add list str[i] str i if(list.size()>2){
			System.out.println("No");
		}else{
			if(cnt==2){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		} list.size()>2 list.size() list.size list 2 {
			System.out.println("No");
		} System.out.println("No") System.out.println System.out System System.out "No" {
			if(cnt==2){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		} if(cnt==2){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			} cnt==2 cnt 2 {
				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[] str=(sc.next()).split("");

		sc.close();

		List<String> list=new ArrayList<String>();

		int cnt=0;

		for(int i=0;i<4;i++){
			if(list.contains(str[i])){
				cnt++;
			}else{
				list.add(str[i]);
			}
		}

		if(list.size()>2){
			System.out.println("No");
		}else{
			if(cnt==2){
				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[] str=(sc.next()).split("");

		sc.close();

		List<String> list=new ArrayList<String>();

		int cnt=0;

		for(int i=0;i<4;i++){
			if(list.contains(str[i])){
				cnt++;
			}else{
				list.add(str[i]);
			}
		}

		if(list.size()>2){
			System.out.println("No");
		}else{
			if(cnt==2){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}


	}
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args){

		Scanner sc=new Scanner(System.in);

		String[] str=(sc.next()).split("");

		sc.close();

		List<String> list=new ArrayList<String>();

		int cnt=0;

		for(int i=0;i<4;i++){
			if(list.contains(str[i])){
				cnt++;
			}else{
				list.add(str[i]);
			}
		}

		if(list.size()>2){
			System.out.println("No");
		}else{
			if(cnt==2){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}


	}
}
