#include<iostream>
#include<cstring>
#include<cmath>
#define int long long
using namespace std;
const int N=1e6+5;
int l,r,ans,dis[N];
bool vis[N];
void check(int x)
{
ans=0;
for(int i=2;i<=x;i++)
{
if(!vis[i])
{
dis[++ans]=i;
for(int j=i;j<=x;j+=i)
{
vis[j]=true;
}
}
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>l>>r;
check((int)sqrt(r));
memset(vis, 0, sizeof vis);
for(int i=1;i<=ans;i++)
{
int q=dis[i];
if(l%q==0)
{
for(int j=l;j<=r;j+=q)
{
vis[j - l + 1]=true;
}
}
else
{
for(int j=(l/q+1)*q;j<=r;j+=q)
{
vis[j - l + 1]=true;
}
vis[q] = false;
}
}
vis[1] = true;
int ans1 = 0;
for(int i=l;i<=r;i++)
{
if(!vis[i - l + 1])
{
ans1++;
}
}
cout<<ans1;
return 0;
}