#include <bits/stdc++.h>
using namespace std;
int n,m,sum;
bool vis[2000005];
int main(){
cin >> n >> m;
for(int i=1;i<=m;i++)vis[i]=1;
vis[1] = 0;
for(int i=2;i<=sqrt(m);i++){
if(!vis[i])continue;
for(int j=i*2;j<=m;j+=i)
vis[j] = 0;
}for(int i=n;i<=m;i++)
if(vis[i])sum++;
cout << sum;
}