def sum(A:int)->int: A = A * (1 - 2 * (A < 0)) # A=abs(A) if A//10 > 0: return A%10 + sum(A//10) else: return A num_end = int(input()) num_multiply = int(input()) with open("e.txt", "w") as file: for i in range(2, num_end+1): if sum(i) == sum(i*num_multiply): file.write(f"{i}\n")