import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String first = s.substring(0,1);
        String second = s.substring(1,2);
        String third = s.substring(2,3);
        String forth = s.substring(3,4);
        if (first.equals(second)) {
            if (third.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        
        if (first.equals(third)) {
            if (second.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        
        if (first.equals(forth)) {
            if (second.equals(third)&& !first.equals(third)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        System.out.println("No");
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String first = s.substring(0,1);
        String second = s.substring(1,2);
        String third = s.substring(2,3);
        String forth = s.substring(3,4);
        if (first.equals(second)) {
            if (third.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        
        if (first.equals(third)) {
            if (second.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        
        if (first.equals(forth)) {
            if (second.equals(third)&& !first.equals(third)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        System.out.println("No");
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String first = s.substring(0,1);
        String second = s.substring(1,2);
        String third = s.substring(2,3);
        String forth = s.substring(3,4);
        if (first.equals(second)) {
            if (third.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        
        if (first.equals(third)) {
            if (second.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        
        if (first.equals(forth)) {
            if (second.equals(third)&& !first.equals(third)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        System.out.println("No");
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String first = s.substring(0,1);
        String second = s.substring(1,2);
        String third = s.substring(2,3);
        String forth = s.substring(3,4);
        if (first.equals(second)) {
            if (third.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        
        if (first.equals(third)) {
            if (second.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        
        if (first.equals(forth)) {
            if (second.equals(third)&& !first.equals(third)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        System.out.println("No");
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc String first = s.substring(0,1); first s.substring(0,1) s.substring s 0 1 String second = s.substring(1,2); second s.substring(1,2) s.substring s 1 2 String third = s.substring(2,3); third s.substring(2,3) s.substring s 2 3 String forth = s.substring(3,4); forth s.substring(3,4) s.substring s 3 4 if (first.equals(second)) {
            if (third.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        } first.equals(second) first.equals first second {
            if (third.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        } if (third.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            } third.equals(forth)&& !first.equals(forth) third.equals(forth) third.equals third forth !first.equals(forth) first.equals(forth) first.equals first forth {
                
                System.out.println("Yes");
                return;
            } System.out.println("Yes") System.out.println System.out System System.out "Yes" return; System.out.println("No") System.out.println System.out System System.out "No" return; if (first.equals(third)) {
            if (second.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        } first.equals(third) first.equals first third {
            if (second.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        } if (second.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            } second.equals(forth)&& !first.equals(forth) second.equals(forth) second.equals second forth !first.equals(forth) first.equals(forth) first.equals first forth {
                
                System.out.println("Yes");
                return;
            } System.out.println("Yes") System.out.println System.out System System.out "Yes" return; System.out.println("No") System.out.println System.out System System.out "No" return; if (first.equals(forth)) {
            if (second.equals(third)&& !first.equals(third)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        } first.equals(forth) first.equals first forth {
            if (second.equals(third)&& !first.equals(third)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        } if (second.equals(third)&& !first.equals(third)) {
                
                System.out.println("Yes");
                return;
            } second.equals(third)&& !first.equals(third) second.equals(third) second.equals second third !first.equals(third) first.equals(third) first.equals first third {
                
                System.out.println("Yes");
                return;
            } System.out.println("Yes") System.out.println System.out System System.out "Yes" return; System.out.println("No") System.out.println System.out System System.out "No" return; System.out.println("No") System.out.println System.out System System.out "No" String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String first = s.substring(0,1);
        String second = s.substring(1,2);
        String third = s.substring(2,3);
        String forth = s.substring(3,4);
        if (first.equals(second)) {
            if (third.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        
        if (first.equals(third)) {
            if (second.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        
        if (first.equals(forth)) {
            if (second.equals(third)&& !first.equals(third)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        System.out.println("No");
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String first = s.substring(0,1);
        String second = s.substring(1,2);
        String third = s.substring(2,3);
        String forth = s.substring(3,4);
        if (first.equals(second)) {
            if (third.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        
        if (first.equals(third)) {
            if (second.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        
        if (first.equals(forth)) {
            if (second.equals(third)&& !first.equals(third)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        System.out.println("No");
    }
} Main
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String first = s.substring(0,1);
        String second = s.substring(1,2);
        String third = s.substring(2,3);
        String forth = s.substring(3,4);
        if (first.equals(second)) {
            if (third.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        
        if (first.equals(third)) {
            if (second.equals(forth)&& !first.equals(forth)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        
        if (first.equals(forth)) {
            if (second.equals(third)&& !first.equals(third)) {
                
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
            return;
        }
        System.out.println("No");
    }
}