Irrelevant Elements

No attempts yetTime limit2sMemory limit128 MB

Problem

Georgie is experimenting with a scheme for generating a pseudo-random integer in the range 00 to m1m-1.

He first fixes nn and generates nn integers a1,a2,,ana_1, a_2, \ldots, a_n, each in the range 00 to m1m-1. He then repeatedly replaces the current array with the array of sums of adjacent elements: from a1,a2,,ana_1, a_2, \ldots, a_n he forms a1+a2,a2+a3,,an1+ana_1 + a_2, a_2 + a_3, \ldots, a_{n-1} + a_n (which has n1n-1 elements), and applies the same step again and again until a single number remains. That last number, taken modulo mm, is the output of the scheme.

A weakness of this scheme is that the final result sometimes does not depend on some of the originally generated numbers. For example, when n=3n = 3 and m=2m = 2 the result never depends on a2a_2.

Call the ii-th original element irrelevant if the final result never depends on aia_i, no matter how the other numbers are chosen. Given nn and mm, determine which elements are irrelevant.

Input

A single line with two integers nn and mm (1n1000001 \le n \le 100\,000, 2m1092 \le m \le 10^9).

Output

On the first line, print the number of irrelevant elements. On the second line, print in ascending order, separated by single spaces, the indices ii of all irrelevant elements. If there are no irrelevant elements, print an empty second line.