#include #include #include #include using namespace std; using ll = long long; const string no = "#"; map memo; string calc(ll n){ if(n == 1)return ""; if(memo.find(n) != memo.end())return memo[n]; string res = no; if((n - 1) % 2 == 0){ string a = calc((n - 1) / 2); if(a != no)res = a + "A"; } if((n - 1) % 3 == 0){ string a = calc((n - 1) / 3); if(a != no)res = a + "B"; } return memo[n] = res; } ll N; int main(void){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> N; string s = calc(N); cout << s << endl; return 0; }