import sys, math sys.setrecursionlimit(10**8) ans = [] def dfs(record:list, x:int): global ans if x == 1: ans = record[:] return if (x - 1)%2 == 0: record.append('A') newx = (x - 1)//2 dfs(record, newx) record.pop() if (x - 1)%3 == 0: record.append('B') newx = (x - 1)//3 dfs(record, newx) record.pop() N = int(input()) if N == 1: exit(print()) dfs([], N) ans.reverse() print(''.join(ans))