#include <bits/stdc++.h>

using namespace std;

// Optimization stuff
inline void debugMode() {
    #ifndef ONLINE_JUDGE
    freopen("debug.in", "r", stdin);
    #endif // ONLINE_JUDGE
}

inline void optimizeIt() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
}
// End optimization stuff

inline double ABS(const int &x) {
    return max(x, -x);
}

inline bool isPrime(const long long int &x) {
    if(x == 1) return false;

    for(long long int d = 2; d * d <= x; d++) {
        if(x % d == 0) return false;
    }

    return true;
}

inline int GCD(int a, int b) {
    while(b) {
        int r = a % b;
        a = b;
        b = r;
    }
    return a;
}

typedef long long int ll;
typedef long double ld;

const int NMax = 1000 + 5;
const int LIM = 1e5;
const int MOD = 1e9 + 7;

const int dx[] = {2, 3, 5, 7};

int main(){
    debugMode();
    optimizeIt();

    ll a, b;
    cin >> a >> b;

    int ans = 0;
    deque < ll > nums;
    nums.push_back(0);
    while(!nums.empty()) {
        ll x = nums.front();
        nums.pop_front();

        if(x > b) continue;
        if(x >= a && x <= b) ans++;

        for(int i = 0; i < 4; i++) {
            ll aux = x * 10 + dx[i];

            if(isPrime(aux)) {
                nums.push_back(aux);
            }
        }
    }

    cout << ans;
    return 0;
}