n, k = map(int, input().split()) r = 1 d = 0 while r < k: r *= 2 d += 1 r -= k ans = [] for i in range(1, n): for j in range(i): ans.append("AND " + str(n) + " " + str(j) + " " + str(i)) ans.append("XOR " + str(j) + " " + str(j) + " " + str(i)) ans.append("UPD " + str(i) + " 0") ans.append("XOR " + str(i) + " " + str(i) + " " + str(n)) for i in range(n): if r >> i & 1: for j in range(i, n - 1): ans.append("UPD " + str(n - 1) + " 1") ans.append("AND " + str(n) + " " + str(j) + " " + str(n - 1)) ans.append("XOR " + str(j) + " " + str(j) + " " + str(n - 1)) ans.append("UPD " + str(n - 1) + " 0") ans.append("XOR " + str(n - 1) + " " + str(n - 1) + " " + str(n)) ans.append("UPD " + str(n) + " 1") for i in range(d, n): ans.append("XOR " + str(i) + " " + str(i) + " " + str(n)) for i in range(d, n): ans.append("AND " + str(n) + " " + str(i) + " " + str(n)) ans.append("UPD " + str(0) + " 1") ans.append("XOR " + str(n) + " " + str(0) + " " + str(n)) print(len(ans)) for s in ans: print(s)