#include <bits/stdc++.h>   using namespace std;   template <class T>   void pv(T a, T b) {     for (T i = a; i != b; ++i) cerr << *i <<    ;     cerr << endl;   }   const int MAX_N = 100000;   vector<int> primes;   bool isPrime[MAX_N];   void MakePrimes() {     for (int i = 0; i < (int)(MAX_N); ++i) isPrime[i] = true;     isPrime[0] = isPrime[1] = false;     for (int i = 2; i < MAX_N; i++) {       if (isPrime[i]) {         for (int j = i + i; j < MAX_N; j += i) isPrime[j] = false;       }     }     for (int i = 0; i < (int)(MAX_N); ++i)       if (isPrime[i]) primes.push_back(i);   }   bool a(int n) {     if (n < MAX_N) return isPrime[n];     for (int i = 0; primes[i] * primes[i] <= n; i++)       if (n % primes[i] == 0) return false;     return true;   }   const int MILLION = 1000000;   int h[] = {       0,       39176,   74417,   108284,  141503,  174194,  206333,  238261,       269760,  301101,  332181,  363080,  393993,  424569,  454974,  485275,       515414,  545501,  575503,  605357,  635171,  664771,  694490,  723896,       753318,  782754,  812028,  841364,  870514,  899686,  928780,  957871,       986746,  1015619, 1044521, 1073174, 1101903, 1130652, 1159339, 1188093,       1216688, 1245272, 1273689, 1302081, 1330570, 1358925, 1387240, 1415626,       1443939, 1472195, 1500453, 1528622, 1556702, 1584772, 1612824, 1640857,       1668892, 1696863, 1724880, 1752772, 1780671, 1808647, 1836360, 1864207,       1892075, 1919906, 1947727, 1975510, 2003304, 2031020, 2058719, 2086330,       2113990, 2141713, 2169247, 2196835, 2224515, 2252025, 2279483, 2306931,       2334374, 2361872, 2389450, 2416904, 2444352, 2471679, 2499026, 2526330,       2553802, 2581128, 2608394, 2635613, 2662840, 2690185, 2717374, 2744682,       2771910, 2799109, 2826276, 2853362, 2880505, 2907606, 2934703, 2961881,       2988902, 3016009, 3043022, 3069997, 3097083, 3124226, 3151359, 3178276,       3205350, 3232326, 3259118, 3286023, 3312951, 3339778, 3366670, 3393551,       3420476, 3447272, 3474095, 3500974, 3527908, 3554739, 3581527, 3608315,       3635172, 3662084, 3688865, 3715571, 3742387, 3769101, 3795810, 3822594,       3849184, 3875855, 3902460, 3929085, 3955921, 3982460, 4009128, 4035734,       4062451, 4089090, 4115722, 4142364, 4168923, 4195422, 4221985, 4248402,       4274957, 4301295, 4327912, 4354389, 4380845, 4407487, 4433902, 4460241,       4486724, 4513194, 4539593, 4566061, 4592654, 4619006, 4645360, 4671705,       4698103, 4724481, 4750950, 4777296, 4803668, 4830058, 4856492, 4882798,       4909157, 4935488, 4961878, 4988226, 5014695, 5040863, 5067205, 5093333,       5119591, 5145981, 5172232, 5198500, 5224741, 5250964, 5277359, 5303300,       5329410, 5355703, 5381929, 5408176, 5434359, 5460458, 5486492, 5512631,       5538821, 5564989, 5591257, 5617364, 5643587, 5669724, 5695725, 5721870,       5747922, 5773921, 5800089, 5826127, 5852352, 5878520, 5904577, 5930672,       5956845, 5982939, 6008887, 6034853, 6060852, 6086846, 6112891, 6139005,       6164976, 6191134, 6217047, 6243137, 6268950, 6294880, 6320783, 6346739,       6372759, 6398760, 6424585, 6450524, 6476474, 6502519, 6528444, 6554452,       6580260, 6606273, 6632211, 6657923, 6683806, 6709795, 6735695, 6761489,       6787249, 6813192, 6838975, 6864928, 6890595, 6916351, 6942266, 6968229,       6994053, 7019911, 7045744, 7071649, 7097378, 7123329, 7149099, 7175070,       7200837, 7226696, 7252624, 7278251, 7304018, 7329881, 7355504, 7381276,       7406982, 7432639, 7458445, 7484264, 7509988, 7535700, 7561435, 7587022,       7612748, 7638354, 7664134, 7689731, 7715474, 7741178, 7766793, 7792385,       7818155, 7843890, 7869478, 7895233, 7920913, 7946432, 7972124, 7997861,       8023413, 8049029, 8074668, 8100189, 8125719,   };   int hard(int n) {     int k = 0;     while (k * MILLION <= n) {       k++;     }     k--;     int ans = h[k];     if (k == 0) {       if (2 <= n)         if (a(2)) ++ans;       for (int i = 5; i <= n; i += 4) {         if (a(i)) ++ans;       }       return ans;     } else {       for (int i = k * MILLION + 1; i <= n; i += 4) {         if (a(i)) ++ans;       }       return ans;     }   }   int main() {     MakePrimes();     int L, R;     cin >> L >> R;     cout << hard(R) - hard(L - 1) << endl;     return 0;   }