#include using namespace std; int l, r, m = 0; const long long N = 2e6; bool f[2000001]; int main() { cin >> l >> r; f[1] = 1; for (long long i = 2; i <= N; i++) { if (!f[i]) { for (long long j = i * i; j <= N; j += i) { f[j] = 1; } } } for (long long i = l; i <= r; i++) { if(!f[i]) m++; if (i < r && !f[i * 2 + 1]) m++; } cout << m << endl; }