#include <bits/stdc++.h>
using namespace std;

int main() {
    long long n;
    cin >> n;
    auto f = [&](auto f, long long x) -> string {
        if (x == 1) {
            return "";
        }
        if ((x - 1) % 2 != 0 && (x - 1) % 3 != 0) {
            return "X";
        }
        string res;
        if ((x - 1) % 2 == 0) {
            string s = f(f, (x - 1) / 2);
            if (s != "X") {
                res = "A" + s;
            } else {
                res = "B" + f(f, (x - 1) / 3);
            }
        } else {
            res = "B" + f(f, (x - 1) / 3);
        }
        return res;
    };
    string ans = f(f, n);
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}