#include <iostream>
#include <algorithm>
#define ll long long
constexpr int max_check = 1e5;

using namespace std;
int p, q, r;
bool check(int n)
{
	int res1, res2, res3;
	if (n % p != 0)
		res1 = n / p + 1;
	else
		res1 = n / p;

	if (n % q != 0)
		res2 = n / q + 1;
	else
		res2 = n / q;

	if (n % r != 0)
		res3 = n / r + 1;
	else
		res3 = n / r;

	return n >= (res1 + res2 + res3);
}
int NZD(int a, int b)
{
	if (b == 0)
		return a;
	return NZD(b, a % b);
}
int NZS(int a, int b)
{
	return (a * b) / NZD(a, b);
}
bool periodican(int perioda)
{
	for (size_t i = 0; i < 10; i++)
	{
		if (!check((i + 100) * perioda))
			return false;
	}
	return true;
}
int da_do_kraja(int pocetak)
{
	for (size_t i = pocetak; i <= pocetak+100; i++)
	{
		if (!check(i))
			return false;
	}
	return true;
}
int main()
{
	ll L, R;
	cin >> p >> q >> r >> L >> R;
	ll broj_validnih = 0;
	for (size_t i = L; i <= min(R,L+max_check); i++)
	{
		if (check(i))
			broj_validnih++;
	}
	if (R-L > max_check)
	{
		int perioda = NZS(p, NZS(q, r));
		if (periodican(perioda))
		{
			if (da_do_kraja(min(R, L + max_check)))
			{
				broj_validnih += (R - (L + max_check));
			}
			else
			{
				broj_validnih += (R - (L + max_check-1)) / perioda;
			}
		}
	}
	cout << broj_validnih;
	return 0;
}