#include <iostream>
#define N 1000001
using namespace std;


int main(){
  int a,b,n, sum;
  bool flag[N];
  int c, aa,bb;

  while( cin>>n>>a>>b && (n||a||b) ){

    for( int i=1;i<=n;i++ )
      flag[i] = false;

    if( b>a ){
      sum=b; b=a; a=sum;
    }
    sum=0;
    for( int i=b;i<=n;i++ ){
      if( flag[i] ){
	sum++;
	continue;
      }
      c=0;
      for( int n_ai=i; n_ai>=0 ;n_ai-=a ){
	if( n_ai % b==0 ){
	  ++sum;
	  //	  aa = c;
	  //	  bb = n_ai/b;
	  aa = a*c;
	  bb = n_ai;

	  c = aa+bb;
	  /*
	  cout << "i="<<i<< "\ta="<<a<<" b="<<b
	       <<" aa="<<aa<<" bb="<<bb 
	       << "\tn_ai="<<n_ai
	       << endl;
	  */
	  for( int j=2*c; j<=n;j+=c )
	    flag[j] = true;
	  break;
	}
	c++;
      }

    }
    cout << (n-sum) << endl;
  }

  return 0;
}