import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
  	public static String fiftyfifty(String S)
    {
  		if(S.charAt(0) == S.charAt(3) && S.charAt(1) == S.charAt(2) && S.charAt(0) != S.charAt(1))
          return "Yes";
      	else if(S.charAt(0) == S.charAt(1) && S.charAt(2) == S.charAt(3) && S.charAt(1) != S.charAt(2))
          return "Yes";
      	else if(S.charAt(0) == S.charAt(2) && S.charAt(1) == S.charAt(3) && S.charAt(1) != S.charAt(2))
          return "Yes";
      	else
          return "No";
          
    }
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String output = fiftyfifty(S);
      	System.out.println(output);
	}
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java class Main
{
  	public static String fiftyfifty(String S)
    {
  		if(S.charAt(0) == S.charAt(3) && S.charAt(1) == S.charAt(2) && S.charAt(0) != S.charAt(1))
          return "Yes";
      	else if(S.charAt(0) == S.charAt(1) && S.charAt(2) == S.charAt(3) && S.charAt(1) != S.charAt(2))
          return "Yes";
      	else if(S.charAt(0) == S.charAt(2) && S.charAt(1) == S.charAt(3) && S.charAt(1) != S.charAt(2))
          return "Yes";
      	else
          return "No";
          
    }
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String output = fiftyfifty(S);
      	System.out.println(output);
	}
} Main public static String fiftyfifty(String S)
    {
  		if(S.charAt(0) == S.charAt(3) && S.charAt(1) == S.charAt(2) && S.charAt(0) != S.charAt(1))
          return "Yes";
      	else if(S.charAt(0) == S.charAt(1) && S.charAt(2) == S.charAt(3) && S.charAt(1) != S.charAt(2))
          return "Yes";
      	else if(S.charAt(0) == S.charAt(2) && S.charAt(1) == S.charAt(3) && S.charAt(1) != S.charAt(2))
          return "Yes";
      	else
          return "No";
          
    } fiftyfifty {
  		if(S.charAt(0) == S.charAt(3) && S.charAt(1) == S.charAt(2) && S.charAt(0) != S.charAt(1))
          return "Yes";
      	else if(S.charAt(0) == S.charAt(1) && S.charAt(2) == S.charAt(3) && S.charAt(1) != S.charAt(2))
          return "Yes";
      	else if(S.charAt(0) == S.charAt(2) && S.charAt(1) == S.charAt(3) && S.charAt(1) != S.charAt(2))
          return "Yes";
      	else
          return "No";
          
    } if(S.charAt(0) == S.charAt(3) && S.charAt(1) == S.charAt(2) && S.charAt(0) != S.charAt(1))
          return "Yes";
      	else if(S.charAt(0) == S.charAt(1) && S.charAt(2) == S.charAt(3) && S.charAt(1) != S.charAt(2))
          return "Yes";
      	else if(S.charAt(0) == S.charAt(2) && S.charAt(1) == S.charAt(3) && S.charAt(1) != S.charAt(2))
          return "Yes";
      	else
          return "No"; S.charAt(0) == S.charAt(3) && S.charAt(1) == S.charAt(2) && S.charAt(0) != S.charAt(1) S.charAt(0) == S.charAt(3) && S.charAt(1) == S.charAt(2) && S.charAt(0) != S.charAt(1) S.charAt(0) == S.charAt(3) S.charAt(0) S.charAt S 0 S.charAt(3) S.charAt S 3 S.charAt(1) == S.charAt(2) S.charAt(1) S.charAt S 1 S.charAt(2) S.charAt S 2 S.charAt(0) != S.charAt(1) S.charAt(0) S.charAt S 0 S.charAt(1) S.charAt S 1 return "Yes"; "Yes" if(S.charAt(0) == S.charAt(1) && S.charAt(2) == S.charAt(3) && S.charAt(1) != S.charAt(2))
          return "Yes";
      	else if(S.charAt(0) == S.charAt(2) && S.charAt(1) == S.charAt(3) && S.charAt(1) != S.charAt(2))
          return "Yes";
      	else
          return "No"; S.charAt(0) == S.charAt(1) && S.charAt(2) == S.charAt(3) && S.charAt(1) != S.charAt(2) S.charAt(0) == S.charAt(1) && S.charAt(2) == S.charAt(3) && S.charAt(1) != S.charAt(2) S.charAt(0) == S.charAt(1) S.charAt(0) S.charAt S 0 S.charAt(1) S.charAt S 1 S.charAt(2) == S.charAt(3) S.charAt(2) S.charAt S 2 S.charAt(3) S.charAt S 3 S.charAt(1) != S.charAt(2) S.charAt(1) S.charAt S 1 S.charAt(2) S.charAt S 2 return "Yes"; "Yes" if(S.charAt(0) == S.charAt(2) && S.charAt(1) == S.charAt(3) && S.charAt(1) != S.charAt(2))
          return "Yes";
      	else
          return "No"; S.charAt(0) == S.charAt(2) && S.charAt(1) == S.charAt(3) && S.charAt(1) != S.charAt(2) S.charAt(0) == S.charAt(2) && S.charAt(1) == S.charAt(3) && S.charAt(1) != S.charAt(2) S.charAt(0) == S.charAt(2) S.charAt(0) S.charAt S 0 S.charAt(2) S.charAt S 2 S.charAt(1) == S.charAt(3) S.charAt(1) S.charAt S 1 S.charAt(3) S.charAt S 3 S.charAt(1) != S.charAt(2) S.charAt(1) S.charAt S 1 S.charAt(2) S.charAt S 2 return "Yes"; "Yes" return "No"; "No" String S S public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String output = fiftyfifty(S);
      	System.out.println(output);
	} main {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String output = fiftyfifty(S);
      	System.out.println(output);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc String output = fiftyfifty(S); output fiftyfifty(S) fiftyfifty S System.out.println(output) System.out.println System.out System System.out output String[] args args
import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
  	public static String fiftyfifty(String S)
    {
  		if(S.charAt(0) == S.charAt(3) && S.charAt(1) == S.charAt(2) && S.charAt(0) != S.charAt(1))
          return "Yes";
      	else if(S.charAt(0) == S.charAt(1) && S.charAt(2) == S.charAt(3) && S.charAt(1) != S.charAt(2))
          return "Yes";
      	else if(S.charAt(0) == S.charAt(2) && S.charAt(1) == S.charAt(3) && S.charAt(1) != S.charAt(2))
          return "Yes";
      	else
          return "No";
          
    }
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String output = fiftyfifty(S);
      	System.out.println(output);
	}
}