#include <stdio.h>

int nums[100001], nums_n;

int main(){
	freopen("irrelevant.in", "r" ,stdin);
	freopen("irrelevant.out", "w" ,stdout);
	int m, n, lim, i, last;
	__int64 coef = 1;
	nums_n = 0;
	scanf("%d %d\n", &n, &m);
	lim = n/2 + 1;
	lim = n-1;
	for (i=2; i<=lim; i++) {
		/*if (coef % (i-1) == 0) {
			coef = coef / (i-1) * (n-i+1);
		}
		else {
			coef = (n - i+1) / (i-1) * coef;
		}*/
		coef = coef * (n-i+1) / (i-1);
		if (coef % (__int64) m == 0) nums[nums_n++] = i;
	}
	/*last = nums_n;
	for (i=0; i<last; i++) {
		if (nums[i] <= n/2) nums[last++] = 
	}*/
	printf("%d\n", nums_n);
	for (i=0; i<nums_n; i++) printf("%d ", nums[i]);
	printf("\n");
	return 0;
}