#include using namespace std; #include using namespace atcoder; #define ll long long #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) //using mint = modint998244353; const int dx[4]={0,1,0,-1}; const int dy[4]={1,0,-1,0}; ll n; string f(ll x, string a) { if (x == 1) return a; if((x-1ll)%2ll==0){ string res = f((x-1ll)/2ll, a + 'A'); if (!res.empty()){ return res; } } if((x-1ll)%3ll==0){ string res2 = f((x-1ll)/ 3ll, a + 'B'); if (!res2.empty()){ return res2; } } return ""; } int main() { cin >> n; ll x = 1; string a; a = f(n, ""); reverse(a.begin(),a.end()); cout << a << endl; return 0; }