// irrelevant.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include <fstream>
#include <vector>
#include <deque>
#include <iostream>
typedef unsigned int mint;

std::vector<mint> mas;
mint n, m;
int main(int argc, char* argv[])
{
	std::ifstream in("irrelevant.in");
	std::ofstream out("irrelevant.out");
	in >>n >>m;
	mas.resize(n);
	for (size_t i = 0;i < n;i++) mas[i] = 0;
	mas[0] = 1;
	int s = 1;
	for (;;)
	{
		for (int i = s-1;i >= 0;i--)
			mas[i+1] += mas[i];
		s++;
		if (s == n) break;
		
	}
	int c = 0;
	std::deque<int> d;
	for ( i = 0;i < n;i++)
	if(mas[i] % m == 0)
	{
		c++;
		d.push_back(i+1);
	}
	out <<c <<std::endl;
	for (i = 0;i < d.size();i++)
	{
		out <<d[i];
		if (i != d.size()-1) out <<" ";
	}


	return 0;
}

