import sys sys.setrecursionlimit(10**6) import pypyjit pypyjit.set_param('max_unroll_recursion=-1') N = int(input()) def dfs(x,y): if x <= 1: if x == 1: print("".join(y[::-1])) exit() else: return if x%2 == 0 and (x-1)%3 == 0: y.append("B") dfs((x-1)//3,y) y.pop() if (x-1)%2 == 0: y.append("A") dfs((x-1)//2,y) y.pop() if (x-1)%3 == 0: y.append("B") dfs((x-1)//3,y) y.pop() dfs(N,[])