#include <iostream>
#include<cmath>
using namespace std;
int main()
{
int a,b;
int x,i,count=0;
cin>>a>>b;
if(a!=0&&a!=1){
for(x=a;x<=b;x++)
{
for(i=2;i<=sqrt(x);i++)
{if(x%i==0) break;}
if(i>sqrt(x)) count++;}}
else if(a==0){
count=-2;
for(x=a;x<=b;x++)
{
for(i=2;i<=sqrt(x);i++)
{if(x%i==0) break;}
if(i>sqrt(x)) count++;}
}
else if(a==1){
count=-1;
for(x=a;x<=b;x++)
{
for(i=2;i<=sqrt(x);i++)
{if(x%i==0) break;}
if(i>sqrt(x)) count++;}
}
cout<<count<<endl;
return 0;
}