import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String ans = "No";
        Map<Character, Integer> map = new HashMap<>();
        for(char c : s.toCharArray()) map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1);
        if(map.size() == 2 && map.containsValue(2)) ans = "Yes";
        System.out.println(ans);
    }
} import java.util.HashMap; HashMap java.util import java.util.Map; Map 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 s = sc.next();
        String ans = "No";
        Map<Character, Integer> map = new HashMap<>();
        for(char c : s.toCharArray()) map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1);
        if(map.size() == 2 && map.containsValue(2)) ans = "Yes";
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String ans = "No";
        Map<Character, Integer> map = new HashMap<>();
        for(char c : s.toCharArray()) map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1);
        if(map.size() == 2 && map.containsValue(2)) ans = "Yes";
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String ans = "No";
        Map<Character, Integer> map = new HashMap<>();
        for(char c : s.toCharArray()) map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1);
        if(map.size() == 2 && map.containsValue(2)) ans = "Yes";
        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 ans = "No"; ans "No" Map<Character, Integer> map = new HashMap<>(); map new HashMap<>() for(char c : s.toCharArray()) map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1); char c s.toCharArray() s.toCharArray s map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1); map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1) map.put map c map.containsKey(c) ? map.get(c) + 1 : 1 map.containsKey(c) map.containsKey map c map.get(c) + 1 map.get(c) map.get map c 1 1 if(map.size() == 2 && map.containsValue(2)) ans = "Yes"; map.size() == 2 && map.containsValue(2) map.size() == 2 map.size() map.size map 2 map.containsValue(2) map.containsValue map 2 ans = "Yes" ans "Yes" System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String ans = "No";
        Map<Character, Integer> map = new HashMap<>();
        for(char c : s.toCharArray()) map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1);
        if(map.size() == 2 && map.containsValue(2)) ans = "Yes";
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String ans = "No";
        Map<Character, Integer> map = new HashMap<>();
        for(char c : s.toCharArray()) map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1);
        if(map.size() == 2 && map.containsValue(2)) ans = "Yes";
        System.out.println(ans);
    }
} Main
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String ans = "No";
        Map<Character, Integer> map = new HashMap<>();
        for(char c : s.toCharArray()) map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1);
        if(map.size() == 2 && map.containsValue(2)) ans = "Yes";
        System.out.println(ans);
    }
}
