import java.util.*;
class Main{
  public static void main(String[] args){
    Set<Character>set = new HashSet<>();
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    set.add(s.charAt(0));
    set.add(s.charAt(1));
    set.add(s.charAt(2));
    set.add(s.charAt(3));
    if(set.size()==2)System.out.println("Yes");
    else System.out.println("No");
  }
} import java.util.*; util.* java class Main{
  public static void main(String[] args){
    Set<Character>set = new HashSet<>();
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    set.add(s.charAt(0));
    set.add(s.charAt(1));
    set.add(s.charAt(2));
    set.add(s.charAt(3));
    if(set.size()==2)System.out.println("Yes");
    else System.out.println("No");
  }
} Main public static void main(String[] args){
    Set<Character>set = new HashSet<>();
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    set.add(s.charAt(0));
    set.add(s.charAt(1));
    set.add(s.charAt(2));
    set.add(s.charAt(3));
    if(set.size()==2)System.out.println("Yes");
    else System.out.println("No");
  } main {
    Set<Character>set = new HashSet<>();
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    set.add(s.charAt(0));
    set.add(s.charAt(1));
    set.add(s.charAt(2));
    set.add(s.charAt(3));
    if(set.size()==2)System.out.println("Yes");
    else System.out.println("No");
  } Set<Character>set = new HashSet<>(); set new HashSet<>() Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc set.add(s.charAt(0)) set.add set s.charAt(0) s.charAt s 0 set.add(s.charAt(1)) set.add set s.charAt(1) s.charAt s 1 set.add(s.charAt(2)) set.add set s.charAt(2) s.charAt s 2 set.add(s.charAt(3)) set.add set s.charAt(3) s.charAt s 3 if(set.size()==2)System.out.println("Yes");
    else System.out.println("No"); set.size()==2 set.size() set.size set 2 System.out.println("Yes") System.out.println System.out System System.out "Yes" System.out.println("No") System.out.println System.out System System.out "No" String[] args args
import java.util.*;
class Main{
  public static void main(String[] args){
    Set<Character>set = new HashSet<>();
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    set.add(s.charAt(0));
    set.add(s.charAt(1));
    set.add(s.charAt(2));
    set.add(s.charAt(3));
    if(set.size()==2)System.out.println("Yes");
    else System.out.println("No");
  }
}
