#include<iostream>
#include<cmath>
using namespace std;
bool isPrime(int num){
if(num<=1)
return false;
int a=sqrt(num);
for(int i=2;i<=a;i++){
if (num%i==0)
return false;
}
return true;
}
int countPrimesBetween(int a,int b){
int count=0;
if(a>b)
swap(a,b);
for(int i=a;i<=b;i++){
if(isPrime(i))
count++;
}
return count;
}
int main(){
int num1,num2;
cin>>num1>>num2;
int primeCount=countPrimesBetween(num1,num2);
cout<<primeCount<<endl;
return 0;
}