#include <iostream>
#include <queue>

using namespace std;

void solve()
{
	int s;
	while(cin >> s, s)
	{
		int t;
		cin >> t;
		deque<bool> flag(t + 1);
		int count1 = 0;
		if(s == 1)
		{
			++count1;
		}
		queue<int> hamming;
		hamming.push(1);
		while(!hamming.empty())
		{
			int n = hamming.front();
			hamming.pop();
			if(n * 2 <= t && !flag[n * 2])
			{
				flag[n * 2] = true;
				hamming.push(n * 2);
				++count1;
			}
			if(n * 3 <= t && !flag[n * 3])
			{
				flag[n * 3] = true;
				hamming.push(n * 3);
				++count1;
			}
			if(n * 5 <= t && !flag[n * 5])
			{
				flag[n * 5] = true;
				hamming.push(n * 5);
				++count1;
			}
		}

		deque<bool> flag2(s + 1);
		int count2 = 0;
		queue<int> hamming2;
		hamming2.push(1);
		while(!hamming2.empty())
		{
			int n = hamming2.front();
			hamming2.pop();
			if(n * 2 < s && !flag2[n * 2])
			{
				flag2[n * 2] = true;
				hamming2.push(n * 2);
				++count2;
			}
			if(n * 3 < s && !flag2[n * 3])
			{
				flag2[n * 3] = true;
				hamming2.push(n * 3);
				++count2;
			}
			if(n * 5 < s && !flag2[n * 5])
			{
				flag2[n * 5] = true;
				hamming2.push(n * 5);
				++count2;
			}
		}
		/*int count2 = 0;
		for(int i = 0; i < s; ++i)
		{
			if(flag[i])
			{
				++count2;
			}
		}*/
		cout << count1 - count2 << endl;		
	}
}

int main()
{
	solve();
	return(0);
}