import sys, time, random from collections import deque, Counter, defaultdict input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 61 - 1 mod = 998244353 def f(x, S): if x == 1: return S if (x - 1) // 2 >= 1 and (x - 1) % 2 == 0: p = f((x - 1) // 2, S + 'A') if p is not None: return p if (x - 1) // 3 >= 1 and (x - 1) % 3 == 0: p = f((x - 1) // 3, S + 'B') if p is not None: return p return None print(f(ii(), '')[::-1])