#include <stdio.h>
#include <stdlib.h>

long int N;
long int *a;
long int M;
long int Count;
long int D[30];
long int t;
long int *Save;
long int *C;
long int **Countz;
int Num[30];
int Number;



void FileRead()
{
	FILE *input = fopen("irrelevant.in", "r");
	fscanf(input, "%ld %ld", &N, &M);
	fclose(input);
}

long int Counting(long int k, long int p)
{
	long int Numer = 0;

	while( k != 0 )
	{
		k /= p;
		Numer += k;
	}
	return Numer;
}

void Razloz(long int M)
{
	int i;
	Number = 0;
	while( M > 1 )
	{
		for(i=2; i<=M; i++)
		{
			if( M%i == 0 )
			{
				if( Number == 0 )
				{
					D[0] = i;
					Num[0] = 1;
					Number = 1;
				}
				else 
				{
					if( i == D[ Number-1 ] )
					{
						Num[ Number-1 ]++;
					}
					else
					{
						Num[ Number ] = 1;
						D[ Number ] = i;
						Number++;
					}
				}
				M /= i;
				break;
			}
		}
	}
}

void Init()
{
	long int i, j, C;
	

	for(i=0; i<Number; i++)
	{
		Countz[i][0] = 0;
		for(j=1; j<N; j++)
		{
			Countz[i][j] = Countz[i][j-1];
			C = j;
			while( C%D[i] == 0 )
			{
				C /= D[i];
				Countz[i][j]++;
			}
		}
	}
}

void Solution()
{
	long int i, j, temp;
	
	C	 = (long int*)calloc (30,sizeof(long int));
	Save = (long int*)malloc (100001*sizeof(long int));
	Countz = (long int**)malloc (30*sizeof(long int*));
	for(i=0; i<30; i++)
		Countz[i] = (long int*) malloc(100001*sizeof(long int));
	
	Init();

	t = 0;
	for(i=1; i<N; i++)
	{
		for(j=0; j<Number; j++)
		{
			temp = i;
			while( temp%D[j] == 0 )
			{
				C[j]--;
				temp /= D[j];
			}
			temp = N-i;
			while( temp%D[j] == 0 )
			{
				C[j]++;
				temp /= D[j];
			}

			if( C[j] >= Num[j] )
			{
				continue;
			}
			else
			{
				break;
			}	
		}
		if( j == Number )
		{
			Count++;
			Save[t++] = i;
		}
		
	}
}

void FileWrite()
{
	int i;
	FILE *output = fopen("irrelevant.out", "w");
	fprintf(output, "%ld\n", Count);
	for(i=0; i<t; i++)
	{
		fprintf(output, "%ld ", Save[i]+1);
	}
	/*for(i=0; i<Number; i++)
		fprintf(output, "%d\n", D[i]);*/
	fclose(output);
}

int main()
{
	FileRead();
	Razloz(M);
	Solution();
	FileWrite();
	return 0;
}