n = int(input()) d = dict() d[1] = 1 def calc(x): if x in d: return 1 if (x-1) % 2 == 0 and calc((x-1) // 2) == 1: d[x] = 1 return 1 if (x-1) % 3 == 0 and calc((x-1) // 3) == 1: d[x] = 1 return 1 d[x] = 0 return 0 assert(calc(n)) x = n a = [] while x > 1: if (x - 1) % 2 == 0 and calc((x-1) // 2) == 1: x = (x-1) // 2 a.append('A') else: assert (x - 1) % 3 == 0 and calc((x - 1) // 3) == 1 x = (x-1) // 3 a.append('B') print(''.join(a[::-1]))