n = int(input()) nn = n // 3 ans = [] x, xx = 0, 0 while xx <= nn: k = n + xx yy = x << 1 yyy = yy * yy while yyy <= k: if yy == 0 or k % yy > 0: yyy += (yy << 1) | 1 yy += 1 continue y, z = yy - x, k // yy - x if x != y and y != z: ans.append([x, y, z]) ans.append([x, z, y]) ans.append([y, x, z]) ans.append([y, z, x]) ans.append([z, x, y]) ans.append([z, y, x]) elif x != y or y != z: ans.append([x, y, z]) ans.append([y, z, x]) ans.append([z, x, y]) else: ans.append([x, y, z]) yyy += (yy << 1) | 1 yy += 1 xx += (x << 1) | 1 x += 1 print(len(ans)) for i in ans: print(*i)