n,K=map(int,input().split()) import sys sys.setrecursionlimit(10**6) s=[] q=[0] def f(): global K if len(s)==n-2: if q[-1]==0 and s[-1:]!=list("M"): return if len(s)==n-1: if q[-1]==0 and s[-2:]!=list("MM"): return if len(s)==n: if q[-1]==0: return K-=1 if K==0: print("".join(s)) exit() return for c in "AM": s.append(c) q.append(q[-1]|(len(s)>=3 and s[-3:]==list("MMA"))) f() s.pop() q.pop() return f()