#include #include #include using namespace std ; /*ifstream cin ("input") ; ofstream cout ("output") ;*/ int cif [] = {2,3,5,7} ; bool isPrime (long long n) { if (n == 1) return false ; if (n == 2) return true ; if (n == 3) return true ; long long d = 2 ; while (d * d <= n) { if (n % d == 0) { return false ; } d += 1 ; } return true ; } vector sol ; void compute (long long cur) { if (cur > (long long)(1e9)) { return ; } if (isPrime(cur)) { sol.push_back(cur) ; for (int i = 0 ; i < 4 ; ++ i) { compute (cur * 10 + cif[i]) ; } } } int main(int argc, char const *argv[]) { compute(0) ; int a , b ; cin >> a >> b ; assert (a >= 1 and b >= 1) ; int ans = 0 ; for (auto x : sol) { if (x >= a and x <= b) { ans += 1 ; } } cout << ans << '\n' ; return 0; }