from functools import lru_cache @lru_cache(maxsize=None) def grundy(x): if x == 0 or x == 1: return 0 if x == 2: return 1 S = set() if x >= 2: a = x // 2 b = x - a S.add(grundy(a) ^ grundy(b)) if x % 3 == 1: S.add(grundy(x // 3 + 1)) else: S.add(grundy(x // 3)) S = sorted(S) for i, s in enumerate(S): if i == s: continue return i return i + 1 N = int(input()) if grundy(N): print("A") else: print("B")