#include <stdio.h>
#include <stdlib.h>
typedef unsigned char uchar;
void crible( uchar* t, int p, int n)
{ int x;
  x = p * p;
  while ( x < n ){
    t[x] = 0;
    x += p;
  }
}
int main( int argc, char*argv[] )
{ int n, s, x;
  uchar* t;
  int cpt=0;
  n = atoi( argv[1] );
  s = atoi( argv[2] );
  t= (uchar*) 
      calloc( n , sizeof(uchar));
  for( x = 2; x < n; x++ )
    t[x] = 1;
  for( x = 2; x < n; x++ )
    if ( t[x] )
      crible(t, x, n);
  for( x = 0; x < n; x++ ){
   if ( t[x] ) cpt++;
   if ( 0 == x % s )
     printf("\npi(%d) = %d", x, cpt);
  }
  return 0;
}
