import static java.lang.Math.abs;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String S=sc.next();
        sc.close();
        int count=0;
        for(int i=0;i<S.length();i++){
            if(S.charAt(i)=='A') count++;
            else count--;
        }
        if(abs(count)==3)System.out.println("No");
        else System.out.println("Yes");    
    }
} import static java.lang.Math.abs; import static java.lang.Math.abs; import static java.lang.Math.abs; 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();
        sc.close();
        int count=0;
        for(int i=0;i<S.length();i++){
            if(S.charAt(i)=='A') count++;
            else count--;
        }
        if(abs(count)==3)System.out.println("No");
        else System.out.println("Yes");    
    }
} Main public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String S=sc.next();
        sc.close();
        int count=0;
        for(int i=0;i<S.length();i++){
            if(S.charAt(i)=='A') count++;
            else count--;
        }
        if(abs(count)==3)System.out.println("No");
        else System.out.println("Yes");    
    } main {
        Scanner sc=new Scanner(System.in);
        String S=sc.next();
        sc.close();
        int count=0;
        for(int i=0;i<S.length();i++){
            if(S.charAt(i)=='A') count++;
            else count--;
        }
        if(abs(count)==3)System.out.println("No");
        else System.out.println("Yes");    
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String S=sc.next(); S sc.next() sc.next sc sc.close() sc.close sc int count=0; count 0 for(int i=0;i<S.length();i++){
            if(S.charAt(i)=='A') count++;
            else count--;
        } int i=0; int i=0; i 0 i<S.length() i S.length() S.length S i++ i++ i {
            if(S.charAt(i)=='A') count++;
            else count--;
        } {
            if(S.charAt(i)=='A') count++;
            else count--;
        } if(S.charAt(i)=='A') count++;
            else count--; S.charAt(i)=='A' S.charAt(i) S.charAt S i 'A' count++ count count-- count if(abs(count)==3)System.out.println("No");
        else System.out.println("Yes"); abs(count)==3 abs(count) abs count 3 System.out.println("No") System.out.println System.out System System.out "No" System.out.println("Yes") System.out.println System.out System System.out "Yes" String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String S=sc.next();
        sc.close();
        int count=0;
        for(int i=0;i<S.length();i++){
            if(S.charAt(i)=='A') count++;
            else count--;
        }
        if(abs(count)==3)System.out.println("No");
        else System.out.println("Yes");    
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String S=sc.next();
        sc.close();
        int count=0;
        for(int i=0;i<S.length();i++){
            if(S.charAt(i)=='A') count++;
            else count--;
        }
        if(abs(count)==3)System.out.println("No");
        else System.out.println("Yes");    
    }
} Main
import static java.lang.Math.abs;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String S=sc.next();
        sc.close();
        int count=0;
        for(int i=0;i<S.length();i++){
            if(S.charAt(i)=='A') count++;
            else count--;
        }
        if(abs(count)==3)System.out.println("No");
        else System.out.println("Yes");    
    }
}