#ax,ay,az=map(int, input().split()) #bx,by,bz=map(int, input().split()) N=int(input()) D={} import heapq A=[] heapq.heappush(A,(N,0)) while A: x,c=heapq.heappop(A) D[x]=c if x==1: break if (x-1)%2==0: p=(x-1)//2 q=c*3+1 heapq.heappush(A,(p,q)) if (x-1)%3==0: p=(x-1)//3 q=c*3+2 heapq.heappush(A,(p,q)) c=D[1] ans=[] while c: if c%3==1: ans.append('A') elif c%3==2: ans.append('B') c//=3 print(''.join(ans))