import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final int MAX = 100100;
    InputStream in = System.in;
    PrintStream out = System.out;
    // static int dp[][] = new int[MAX][MAX];

    public void _main(String[] args) {
        Scanner sc = new Scanner(in);
        String S = sc.next();
        char[] s = S.toCharArray();
        Arrays.sort(s);
        if (s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]) out.println("Yes");
        else out.println("No");
    }

    public static void main(String[] args) {
        new Main()._main(args);
    }
} import java.io.InputStream; InputStream java.io import java.io.PrintStream; PrintStream java.io import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    static final int MAX = 100100;
    InputStream in = System.in;
    PrintStream out = System.out;
    // static int dp[][] = new int[MAX][MAX];

    public void _main(String[] args) {
        Scanner sc = new Scanner(in);
        String S = sc.next();
        char[] s = S.toCharArray();
        Arrays.sort(s);
        if (s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]) out.println("Yes");
        else out.println("No");
    }

    public static void main(String[] args) {
        new Main()._main(args);
    }
} Main static final int MAX = 100100; MAX 100100 InputStream in = System.in; in System.in System System.in PrintStream out = System.out; out System.out System System.out public void _main(String[] args) {
        Scanner sc = new Scanner(in);
        String S = sc.next();
        char[] s = S.toCharArray();
        Arrays.sort(s);
        if (s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]) out.println("Yes");
        else out.println("No");
    } _main {
        Scanner sc = new Scanner(in);
        String S = sc.next();
        char[] s = S.toCharArray();
        Arrays.sort(s);
        if (s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]) out.println("Yes");
        else out.println("No");
    } Scanner sc = new Scanner(in); sc new Scanner(in) String S = sc.next(); S sc.next() sc.next sc char[] s = S.toCharArray(); s S.toCharArray() S.toCharArray S Arrays.sort(s) Arrays.sort Arrays s if (s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]) out.println("Yes");
        else out.println("No"); s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2] s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2] s[0]==s[1] s[0] s 0 s[1] s 1 s[2]==s[3] s[2] s 2 s[3] s 3 s[1]!=s[2] s[1] s 1 s[2] s 2 out.println("Yes") out.println out "Yes" out.println("No") out.println out "No" String[] args args public static void main(String[] args) {
        new Main()._main(args);
    } main {
        new Main()._main(args);
    } new Main()._main(args) new Main()._main new Main() args String[] args args public class Main {
    static final int MAX = 100100;
    InputStream in = System.in;
    PrintStream out = System.out;
    // static int dp[][] = new int[MAX][MAX];

    public void _main(String[] args) {
        Scanner sc = new Scanner(in);
        String S = sc.next();
        char[] s = S.toCharArray();
        Arrays.sort(s);
        if (s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]) out.println("Yes");
        else out.println("No");
    }

    public static void main(String[] args) {
        new Main()._main(args);
    }
} public class Main {
    static final int MAX = 100100;
    InputStream in = System.in;
    PrintStream out = System.out;
    // static int dp[][] = new int[MAX][MAX];

    public void _main(String[] args) {
        Scanner sc = new Scanner(in);
        String S = sc.next();
        char[] s = S.toCharArray();
        Arrays.sort(s);
        if (s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]) out.println("Yes");
        else out.println("No");
    }

    public static void main(String[] args) {
        new Main()._main(args);
    }
} Main
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final int MAX = 100100;
    InputStream in = System.in;
    PrintStream out = System.out;
    // static int dp[][] = new int[MAX][MAX];

    public void _main(String[] args) {
        Scanner sc = new Scanner(in);
        String S = sc.next();
        char[] s = S.toCharArray();
        Arrays.sort(s);
        if (s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]) out.println("Yes");
        else out.println("No");
    }

    public static void main(String[] args) {
        new Main()._main(args);
    }
}
