#include <bits/stdc++.h>using namespace std;

// strings at index 0 is not used, it is to make array// indexing simplestring one[] = { "", "one ", "two ", "three ", "four ", "five ", "six ", "seven ", "eight ", "nine ", "ten ", "eleven ", "twelve ", "thirteen ", "fourteen ", "fifteen ", "sixteen ", "seventeen ", "eighteen ", "nineteen " };

// strings at index 0 and 1 are not used, they is to// make array indexing simplestring ten[] = { "", "", "twenty ", "thirty ", "forty ", "fifty ", "sixty ", "seventy ", "eighty ", "ninety " };

// n is 1- or 2-digit numberstring numToWords(int n, string s){ string str = ""; // if n is more than 19, divide it if (n > 19) str += ten[n / 10] + one[n % 10]; else str += one[n];

// if n is non-zero if (n) str += s;

return str;}

// Function to print a given number in wordsstring convertToWords(long n){ // stores word representation of given number n string out;

// handles digits at ten millions and hundred // millions places (if any) out += numToWords((n / 10000000), "crore ");

// handles digits at hundred thousands and one // millions places (if any) out += numToWords(((n / 100000) % 100), "lakh ");

// handles digits at thousands and tens thousands // places (if any) out += numToWords(((n / 1000) % 100), "thousand ");

// handles digit at hundreds places (if any) out += numToWords(((n / 100) % 10), "hundred ");

if (n > 100 && n % 100) out += "and ";

// handles digits at ones and tens places (if any) out += numToWords((n % 100), "");

return out;}

// Driver code

int calculateSpaces(string str){

int count=0;for(unsigned int i=0;i<str.size();i++){

if(str[i]==' ') count++;

}return count;

}

int checkPrime(int num){

if(num%2==0) return false;for(int i=3;i<=sqrt(num);i+=2) if(num%i==0) return false;

return true;

}int main(){int m,n,prcount;

cin>>m; cin>>n; prcount=0; for(int i=m;i<=n;i++) { if(checkPrime(i)) {

string numstr=convertToWords(i); int len=numstr.length(); // cout<<numstr<<numstr.length()<<" spaces "<<calculateSpaces(numstr)<<endl; int spaces=calculateSpaces(numstr); //cout<<len-spaces<<endl; if(checkPrime(len-spaces)) prcount++; // cout<<;

}

}cout<<prcount<<endl; return 0;}