#include using namespace std; using ll=long long; using pll=pair; using tll=tuple; using ld=long double; const ll INF=(1ll<<60); #define rep(i,n) for (ll i=0;i<(ll)(n);i++) #define all(v) v.begin(),v.end() template inline bool chmin(T &a,T b){ if(a>b){ a=b; return true; } return false; } template inline bool chmax(T &a,T b){ if(a mp; string f(ll x){ if(mp.contains(x)) return mp[x]; if(x==1){ return ""; } string ret="X"; if((x-1)%2==0){ ret=f((x-1)/2); ret.push_back('A'); } if((x-1)%3==0){ string s=f((x-1)/3); if(s!="X"){ ret=s; ret.push_back('B'); } } return mp[x]=ret; } int main(){ ios::sync_with_stdio(false); ll n; cin >> n; cout << f(n) << '\n'; }