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

#define rep(i, n) for (int i=0; i<(int)n; i++)
using ll = long long int;

int main() {
  ll N;
  cin >> N;
  auto dfs = [&](auto dfs, ll x, string S) {
    if (x == 1) {
      rep(i, (int)S.size())
	cout << S[(int)S.size() - 1 - i];
      cout << endl;
      return true;
    }
    if (x < 1)
      return false;
    bool ret = false;
    if ((x - 1) % 2 == 0)
      ret = (dfs(dfs, (x -1) / 2, S + "A")) || ret;
    if ((x - 1) % 3 == 0)
      ret = (dfs(dfs, (x-1) / 3, S + "B")) || ret;
    if ((x - 1) % 2 != 0 && (x - 1) % 3 != 0)
      ret = false;
    return ret;
  };
  dfs(dfs, N, "");
  return 0;
}