#include <fstream>

using namespace std;

const int MAX = 100002;

int N, M, Cnt[MAX], MN[MAX], MP[MAX], MCnt, B[MAX], BCnt, P[MAX], PCnt;
int NMN[MAX], NMP[MAX], NMPP[MAX];
bool PP[MAX];

ifstream fin( "irrelevant.in" );
ofstream fout( "irrelevant.out" );

void Fill( int n, int k )
{
   for( ; n!=1; )
   {
      k = 0;
      if( NMPP[n]!=0 )
         return;
      while( n%P[k]!=0 )
         ++k;
      NMN[n] = P[k];
      int n0 = n;
      while( n%P[k]==0 )
      {
         ++NMP[n0];
         n /= P[k];
      }
      NMPP[n0] = n;
   }
}

void Erat()
{
   int i, j;
   for( i = 2; i<MAX; ++i )
      if( !PP[i] )
      {
         P[PCnt++] = i;
         for( j = i+i; j<MAX; j += i )
            PP[j] = true;
      }
}

void Distr( int n, int *DN, int *DP, int &cnt )
{
   cnt = 0;
   int i, t;
   for( i = 0; i<PCnt && n>1; ++i )
   {
      t = P[i];
      if( n%t==0 )
      {
         n /= t;
         DN[cnt] = t;
         DP[cnt] = 1;
         while( n%t==0 )
         {
            n /= t;
            ++DP[cnt];
         }
         ++cnt;
      }
   }
}


void GoM( int n )
{
   for( ; n>1; )
   {
      Cnt[NMN[n]] -= NMP[n];
      n = NMPP[n];
   }
}

void GoP( int n )
{
   for( ; n>1; )
   {
      Cnt[NMN[n]] += NMP[n];
      n = NMPP[n];
   }
}

void ReadData()
{
   fin >> N >> M;
}

void Work()
{
   Distr( M, MN, MP, MCnt );
   int i, j = PCnt-1;
   for( i = N; i>=2; --i )
   {
      Fill( i, j );
   }
   for( i = 1; i<=(N-1)/2; ++i )
   {
      GoM( i );
      GoP( N-i );
/*      Distr( i, TN, TP, TCnt );
      for( j = 0; j<TCnt; ++j )
         Cnt[TN[j]] -= TP[j];
      Distr( N-i, TN, TP, TCnt );
      for( j = 0; j<TCnt; ++j )
         Cnt[TN[j]] += TP[j];*/
      bool ok = true;
      for( j = 0; ok && j<MCnt; ++j )
         if( Cnt[MN[j]]<MP[j] )
            ok = false;
      if( ok )
         B[BCnt++] = i+1;
   }
   for( i = BCnt-1; i>=0; --i )
      if( N-B[i]+1!=B[i] )
         B[BCnt++] = N-B[i]+1;
   fout << BCnt << endl;
   for( i = 0; i<BCnt; ++i )
      fout << B[i] << ' ';
}

int main()
{
   Erat();
   ReadData();
   Work();
   return 0;
}
