from collections import defaultdict import sys sys.setrecursionlimit(10**7) n = int(input()) d = defaultdict(bool) if n == 1: print("") exit() d[1] = True def dfs(now): if now in d: return d[now] if (now - 1) % 2 == 0 and dfs((now - 1) // 2): d[now] = True return True if (now - 1) % 3 == 0 and dfs((now - 1) // 3): d[now] = True return True return False dfs(n) now = n ans = [] while now > 1: if (now - 1) % 2 == 0 and d[(now - 1) // 2]: ans.append("A") now = (now - 1) // 2 else: ans.append("B") now = (now - 1) // 3 ans.reverse() print("".join(ans))