
#include <stdio.h>
#include <string.h>

int n, m;
const int n_max = 200000;

struct verylong {
	int len;
	int val[n_max];
};

void linit(verylong& a) {
	int i;
	for(i = 0;i < n_max;i++)
		a.val[i] = 0;
	a.len = 1;
}

int min(int, int);

void lmul(verylong& a, verylong& b, verylong& c) {
	int s;
	int i, j, k[2];
	
	k[0] = min(a.len, (n + 1) / 2);
	k[1] = min(b.len, (n + 1) / 2);
	
	memset(&c, 0, sizeof(c));
	c.len = k[0] + k[1] - 1;
	
	for (i = 0;i < k[0]; i++)
		for (j = 0;j < k[1]; j++)
			c.val[i + j] += a.val[i] * b.val[j];

	/*s = 0;
	for(i = 0;i < c.len;i++) {
		s += c.val[i];
		c.val[i] = s % 10;
		s /= 10;
	}
	
	while(s > 0) {
		c.val[c.len++] = s % 10;
		s /= 10;
	}*/
}

void lprint(verylong& a) {
	int i;
	for (i = 0; i < n; i++)
		printf("%d", a.val[i]);
	puts("");
}

verylong x, xx, res;
verylong y, z;

int main() {
	int k, i, c;
	
	fclose(stdin); fopen("irrelevant.in", "r");
	fclose(stdout);fopen("irrelevant.out","w");

	scanf("%d %d", &n, &m);
	
	linit(x);
	linit(res);
	x.val[0] = 1;
	x.val[1] = 1;
	x.len = 2;
	
	res.len = 1;
	res.val[0] = 1;
	
	k = n - 1;
	while (k > 0) {
		if (k % 2) {
			lmul(res, x, xx);
			memcpy(&res, &xx, sizeof(verylong));
			k--;
		}
		else {
			lmul(x, x, xx);
			memcpy(&x, &xx, sizeof(verylong));
			k >>= 1;
		}
	}
	
	c = 0;
	for (i = 0; i < (n + 1) >> 1; i++)
		if (res.val[i] % m == 0) c++;
	
	printf("%d\n", c);
	for (i = 0; i < (n + 1) >> 1; i++)
		if (res.val[i] % m == 0) {
			printf("%d ", i + 1);
			if (((n + 1) & 1 == 1) || (i != (((n + 1) >> 1) - 1)))
				printf("%d ", n - i);
		}

	return 0;
}

int min(int x, int y) {
	if(x < y)
		return x;
	return y;
}
