import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String[] s = S.split("");
        Map<String, Integer> map = new HashMap<>();
        for(int i = 0; i < 4; i++) {
            if(map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i])+1);
            }else {
                map.put(s[i], 1);
            }
        }
        
        String ans = "Yes";
        for(int i = 0; i < 4; i++) {
            if(map.get(s[i]) == 2) {
                continue;
            }else {
                ans = "No";
                break;
            }
        }
        
        System.out.println(ans);
        
    }
} import java.util.*; util.* java class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String[] s = S.split("");
        Map<String, Integer> map = new HashMap<>();
        for(int i = 0; i < 4; i++) {
            if(map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i])+1);
            }else {
                map.put(s[i], 1);
            }
        }
        
        String ans = "Yes";
        for(int i = 0; i < 4; i++) {
            if(map.get(s[i]) == 2) {
                continue;
            }else {
                ans = "No";
                break;
            }
        }
        
        System.out.println(ans);
        
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String[] s = S.split("");
        Map<String, Integer> map = new HashMap<>();
        for(int i = 0; i < 4; i++) {
            if(map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i])+1);
            }else {
                map.put(s[i], 1);
            }
        }
        
        String ans = "Yes";
        for(int i = 0; i < 4; i++) {
            if(map.get(s[i]) == 2) {
                continue;
            }else {
                ans = "No";
                break;
            }
        }
        
        System.out.println(ans);
        
    } main {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String[] s = S.split("");
        Map<String, Integer> map = new HashMap<>();
        for(int i = 0; i < 4; i++) {
            if(map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i])+1);
            }else {
                map.put(s[i], 1);
            }
        }
        
        String ans = "Yes";
        for(int i = 0; i < 4; i++) {
            if(map.get(s[i]) == 2) {
                continue;
            }else {
                ans = "No";
                break;
            }
        }
        
        System.out.println(ans);
        
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc String[] s = S.split(""); s S.split("") S.split S "" Map<String, Integer> map = new HashMap<>(); map new HashMap<>() for(int i = 0; i < 4; i++) {
            if(map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i])+1);
            }else {
                map.put(s[i], 1);
            }
        } int i = 0; int i = 0; i 0 i < 4 i 4 i++ i++ i {
            if(map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i])+1);
            }else {
                map.put(s[i], 1);
            }
        } {
            if(map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i])+1);
            }else {
                map.put(s[i], 1);
            }
        } if(map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i])+1);
            }else {
                map.put(s[i], 1);
            } map.containsKey(s[i]) map.containsKey map s[i] s i {
                map.put(s[i], map.get(s[i])+1);
            } map.put(s[i], map.get(s[i])+1) map.put map s[i] s i map.get(s[i])+1 map.get(s[i]) map.get map s[i] s i 1 {
                map.put(s[i], 1);
            } map.put(s[i], 1) map.put map s[i] s i 1 String ans = "Yes"; ans "Yes" for(int i = 0; i < 4; i++) {
            if(map.get(s[i]) == 2) {
                continue;
            }else {
                ans = "No";
                break;
            }
        } int i = 0; int i = 0; i 0 i < 4 i 4 i++ i++ i {
            if(map.get(s[i]) == 2) {
                continue;
            }else {
                ans = "No";
                break;
            }
        } {
            if(map.get(s[i]) == 2) {
                continue;
            }else {
                ans = "No";
                break;
            }
        } if(map.get(s[i]) == 2) {
                continue;
            }else {
                ans = "No";
                break;
            } map.get(s[i]) == 2 map.get(s[i]) map.get map s[i] s i 2 {
                continue;
            } continue; {
                ans = "No";
                break;
            } ans = "No" ans "No" break; System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String[] s = S.split("");
        Map<String, Integer> map = new HashMap<>();
        for(int i = 0; i < 4; i++) {
            if(map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i])+1);
            }else {
                map.put(s[i], 1);
            }
        }
        
        String ans = "Yes";
        for(int i = 0; i < 4; i++) {
            if(map.get(s[i]) == 2) {
                continue;
            }else {
                ans = "No";
                break;
            }
        }
        
        System.out.println(ans);
        
    }
}