#include <stdio.h>
#include <string.h>

int flg[1000001];

int main(void){
	int j;
	int n,a,b;
	int x,ans;

	while(scanf("%d%d%d",&n,&a,&b) && (n||a||b)){
		memset(flg,0,sizeof(flg));
		ans = n;

		for(j=0;j<a;j++){
			x = b*j;
			while(x <= n){
				if(flg[x] == 0) ans--;
				flg[x] = 1;
				x += a;
			}
		}

		printf("%d\n",ans+1);
	}

	return 0;
}