def func(S, x): global ans if x == 1: ans = S return if (x - 1) % 2 == 0: nx = (x - 1) // 2 nS = 'A' + S func(nS, nx) if (x - 1) % 3 == 0: nx = (x - 1) // 3 nS = 'B' + S func(nS, nx) X = int(input()) func('', X) print(ans)