#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//int INF=(1<<31)-1;
//int mi=-(1<<31)+1;
#define read(x) scanf("%d",&x);
#define fo(i,n) for(int i=0;i<(n);i++)
#define one(x) cout<<(x)<<endl;
#define two(a,b) cout<<(a)<<" "<<(b)<<endl;
int main()
{
ios::sync_with_stdio(false);
string s;
cin>>s;
if(s.find("AB")!=-1&&s.find("BA",s.find("AB")+2)!=-1||s.find("BA")!=-1&&s.find("AB",s.find("BA")+2)!=-1)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
return 0;
}