#include <stdio.h>
int main (){
int a,b,i,j,p;
int *ary=calloc(100000000,sizeof(int));ary[0]=1;ary[1]=1;
for(i=0;i<100000000;i++)if(!ary[i])
for(j=i+i;j<100000000;j+=i)ary[j]=1;
while(scanf("%d %d",&a,&b)!=EOF){
if(b<a){//測資有誤,故需要加入B<A的情況
printf("0\n");
continue;
}
else
b++,p=0;
for(i=a;i<b;i++)if(!ary[i])p++;
printf("%d\n",p);
}
return 0;
}