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