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

__int64 curr[100000];
__int64 next[100000];

int main(void)
{
	FILE * in = fopen("irrelevant.in", "rt");
	FILE * out = fopen("irrelevant.out", "wt");

	int n,m,i;
	int cnt = 0;

	fscanf(in, "%d", &n);
	fscanf(in, "%d", &m);

	curr[0] = 1;

	if (n >= 2)
	{
		curr[1] = 2;
		curr[2] = 1;
	}

	for (i = 2; i < (n-1); i++)
	{
		int j;

		next[0] = 1;
		next[i+1] = 1;
		for (j = 0; j < i; j++)
		{
			next[j+1] = curr[j] + curr[j+1];
		}

		memcpy(curr, next, sizeof(curr));
	}

	for (i = 0; i < n; i++)
	{
		if (curr[i] % m == 0) 
		{
			cnt++;
			curr[i] = -1;
		}
	}

	fprintf(out, "%d\n", cnt);
	for (i = 0; i < n; i++)
	{
		if (curr[i] == -1)
			fprintf(out, "%d ", i+1);
	}


	fcloseall();
	return 0;
}
