#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

#include <algorithm>
using namespace std;

int n,m;

int divs[100],nd;
int divp[100];

int res[100000],nr;

int p[100];

void go(int x,int d)
{
  int i;
  for(i=0; i<nd && x>1; i++)
    while(x%divs[i]==0)
    {
      x/=divs[i];
      p[i]+=d;
    }
}

int main()
{
  freopen("irrelevant.in","r",stdin);
  freopen("irrelevant.out","w",stdout);

  int i,j,k;

  scanf("%d %d",&n,&m); n--;

  if (m%2==0)
  {
    nd=1;
    divs[0]=2;
    while(m%2==0)
    {
      m/=2;
      divp[0]++;
    }
  }

  for(i=3; i*i<=m; i+=2)
  if (m%i==0)
  {
    divs[nd]=i;
    while(m%i==0)
    {
      divp[nd]++;
      m/=i;
    }
    nd++;
  }

  if (m>1)
  {
    divs[nd]=m;
    divp[nd]=1;
    nd++;
  }

  for(k=0; k<n; k++)
  {
    // make (n,k+1) from (n,k)

    go(n-k,+1);
    go(k+1,-1);

    for(j=0; j<nd; j++)
      if (divp[j]>p[j]) break;

    if (j==nd)
    {
      res[nr++]=k+2;
    }
  }

  printf("%d\n",nr);
  for(i=0; i<nr; i++) 
  {
    if (i) printf(" ");
    printf("%d",res[i]);
  }
  puts("");

  return 0;
}