from collections import deque N = int(input()) x = 1 deq = deque() deq.append(1) dct = dict() dct[1] = 0 while deq: x2 = 2*x + 1 if x2 <= N and x2 not in dct: dct[x2] = x deq.append(x2) x3 = 3*x + 1 if x3 <= N and x3 not in dct: dct[x3] = x deq.append(x3) x = deq.popleft() ans = [] while True: if dct[N] == 0: break pre = dct[N] if 2*pre + 1 == N: ans.append("A") else: ans.append("B") N = pre ans = list(reversed(ans)) ans = "".join(ans) print(ans)