import java.util.*;
import java.awt.*;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        String s = sc.next();
        char[] list = s.toCharArray();
        ArrayList<Character> c = new ArrayList<Character>();
        String ans = "Yes";
        for(int i = 0; i<4; i++){
            if(!c.contains(list[i])){
                c.add(list[i]);
            }
        }
        for(int i = 0; i<4; i++){
            int count = 0;
            for(int l = 0; l<4; l++){
                if(list[i]==list[l]){
                    count++;
                }
            }
            if(count > 2){
                ans ="No";
            }
        }
        if(c.size() != 2){
            ans ="No";
        }
        System.out.println(ans); 
    }
} import java.util.*; util.* java import java.awt.*; awt.* java class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        String s = sc.next();
        char[] list = s.toCharArray();
        ArrayList<Character> c = new ArrayList<Character>();
        String ans = "Yes";
        for(int i = 0; i<4; i++){
            if(!c.contains(list[i])){
                c.add(list[i]);
            }
        }
        for(int i = 0; i<4; i++){
            int count = 0;
            for(int l = 0; l<4; l++){
                if(list[i]==list[l]){
                    count++;
                }
            }
            if(count > 2){
                ans ="No";
            }
        }
        if(c.size() != 2){
            ans ="No";
        }
        System.out.println(ans); 
    }
} Main private static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {
        String s = sc.next();
        char[] list = s.toCharArray();
        ArrayList<Character> c = new ArrayList<Character>();
        String ans = "Yes";
        for(int i = 0; i<4; i++){
            if(!c.contains(list[i])){
                c.add(list[i]);
            }
        }
        for(int i = 0; i<4; i++){
            int count = 0;
            for(int l = 0; l<4; l++){
                if(list[i]==list[l]){
                    count++;
                }
            }
            if(count > 2){
                ans ="No";
            }
        }
        if(c.size() != 2){
            ans ="No";
        }
        System.out.println(ans); 
    } main {
        String s = sc.next();
        char[] list = s.toCharArray();
        ArrayList<Character> c = new ArrayList<Character>();
        String ans = "Yes";
        for(int i = 0; i<4; i++){
            if(!c.contains(list[i])){
                c.add(list[i]);
            }
        }
        for(int i = 0; i<4; i++){
            int count = 0;
            for(int l = 0; l<4; l++){
                if(list[i]==list[l]){
                    count++;
                }
            }
            if(count > 2){
                ans ="No";
            }
        }
        if(c.size() != 2){
            ans ="No";
        }
        System.out.println(ans); 
    } String s = sc.next(); s sc.next() sc.next sc char[] list = s.toCharArray(); list s.toCharArray() s.toCharArray s ArrayList<Character> c = new ArrayList<Character>(); c new ArrayList<Character>() String ans = "Yes"; ans "Yes" for(int i = 0; i<4; i++){
            if(!c.contains(list[i])){
                c.add(list[i]);
            }
        } int i = 0; int i = 0; i 0 i<4 i 4 i++ i++ i {
            if(!c.contains(list[i])){
                c.add(list[i]);
            }
        } {
            if(!c.contains(list[i])){
                c.add(list[i]);
            }
        } if(!c.contains(list[i])){
                c.add(list[i]);
            } !c.contains(list[i]) c.contains(list[i]) c.contains c list[i] list i {
                c.add(list[i]);
            } c.add(list[i]) c.add c list[i] list i for(int i = 0; i<4; i++){
            int count = 0;
            for(int l = 0; l<4; l++){
                if(list[i]==list[l]){
                    count++;
                }
            }
            if(count > 2){
                ans ="No";
            }
        } int i = 0; int i = 0; i 0 i<4 i 4 i++ i++ i {
            int count = 0;
            for(int l = 0; l<4; l++){
                if(list[i]==list[l]){
                    count++;
                }
            }
            if(count > 2){
                ans ="No";
            }
        } {
            int count = 0;
            for(int l = 0; l<4; l++){
                if(list[i]==list[l]){
                    count++;
                }
            }
            if(count > 2){
                ans ="No";
            }
        } int count = 0; count 0 for(int l = 0; l<4; l++){
                if(list[i]==list[l]){
                    count++;
                }
            } int l = 0; int l = 0; l 0 l<4 l 4 l++ l++ l {
                if(list[i]==list[l]){
                    count++;
                }
            } {
                if(list[i]==list[l]){
                    count++;
                }
            } if(list[i]==list[l]){
                    count++;
                } list[i]==list[l] list[i] list i list[l] list l {
                    count++;
                } count++ count if(count > 2){
                ans ="No";
            } count > 2 count 2 {
                ans ="No";
            } ans ="No" ans "No" if(c.size() != 2){
            ans ="No";
        } c.size() != 2 c.size() c.size c 2 {
            ans ="No";
        } ans ="No" ans "No" System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;
import java.awt.*;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        String s = sc.next();
        char[] list = s.toCharArray();
        ArrayList<Character> c = new ArrayList<Character>();
        String ans = "Yes";
        for(int i = 0; i<4; i++){
            if(!c.contains(list[i])){
                c.add(list[i]);
            }
        }
        for(int i = 0; i<4; i++){
            int count = 0;
            for(int l = 0; l<4; l++){
                if(list[i]==list[l]){
                    count++;
                }
            }
            if(count > 2){
                ans ="No";
            }
        }
        if(c.size() != 2){
            ans ="No";
        }
        System.out.println(ans); 
    }
}
