#include using namespace std; int main() { long long n; cin >> n; string ans = ""; auto f = [&](auto f, long long x) -> bool { if (x == 1) { return true; } if ((x - 1) % 2 == 0 && f(f, (x - 1) / 2) == true) { ans += "A"; return true; } if ((x - 1) % 3 == 0 && f(f, (x - 1) / 3) == true) { ans += "B"; return true; } return false; }; f(f, n); cout << ans << endl; }