import pypyjit pypyjit.set_param('max_unroll_recursion=-1') # https://yukicoder.me/problems/no/2766 from typing import Self class Node: def __init__(self, value, spice='', parent=None) -> None: self.value: int = value self.spice: str = spice self.parent: Self | None = parent def dig(self): if self.value == 1: return self if (self.value - 1) % 2 == 0: if goal := Node(value=(self.value - 1) / 2, spice='A', parent=self).dig(): return goal if (self.value - 1) % 3 == 0: if goal := Node(value=(self.value - 1) / 3, spice='B', parent=self).dig(): return goal def list_spices(self): spices = ['', self.spice] node = self while (p := node.parent) and p.spice: spices.append(p.spice) node = p return spices if __name__ == '__main__': N = int(input()) node = Node(value = N) goal = node.dig() print(''.join(goal.list_spices()))