#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#include<complex>
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int m, n;
	vector<int>v(1000001, 1);
	v[0] = v[1] = 0;
	for (int i = 2; i <= sqrt(1000000); i++) {
		if (v[i]) {
			for (int j = 0; i*(j+2) <= 1000000; j++) {
				v[i*(j+2)] = 0;
			}
		}
	}
	//for (int i = 2; i < 100; i++) {
	//	if (v[i])printf("%4d", i);
	//}
	//cout << endl;

	while (cin >> m >> n, m) {
		int cnt = 0;
		for (int i = m; i <= n; i++) {
			if (i == 1)cnt++;
			bool f = false;
			bool g = false;
			if (i % 2 == 0 || i % 3 == 0 || i % 5 == 0) {
				g = true;
			}
			for (int j = 7; j < i; j++) {
				if (v[j] && i%j == 0) {
					f = true;
					break;
				}
			}
			if (!f&&g)cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}