using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = long.Parse(ReadLine()); var ans = new List(); DFS(n, ans); ans.Reverse(); WriteLine(string.Concat(ans)); } static bool DFS(long cur, List ans) { if (cur == 1) { return true; } if ((cur - 1) % 2 == 0) { ans.Add('A'); if (DFS((cur - 1) / 2, ans)) { return true; } ans.RemoveAt(ans.Count - 1); } if ((cur - 1) % 3 == 0) { ans.Add('B'); if (DFS((cur - 1) / 3, ans)) { return true; } ans.RemoveAt(ans.Count - 1); } return false; } }