def f(n, L): if n == 1: L.reverse() print(*L, sep="") exit() if n % 2 == 1: L.append("A") f((n-1)//2, L) L.pop() if n % 3 == 1: L.append("B") f((n-1)//3, L) L.pop() return N = int(input()) ans = [] f(N, [])