#include <iostream>

using namespace std;
long long int typedef ll;

int nzd(ll a, ll b)
{
	while (true)
	{
		if (a%b == 0) return b;
		if (b%a == 0) return a;
		if (a > b) a %= b;
		else b %= a;
	}
}

ll nzs(ll a, ll b)
{
	return a / nzd(a, b)*b;
}

bool moze(ll p, ll q, ll r, ll n)
{
	if ((n + p - 1) / p + (n + q - 1) / q + (n + r - 1) / r <= n)
	{
		return true;
	}
	return false;
}
ll broj(ll p, ll q, ll r, ll a, ll b)
{
	ll br = 0;
	for (ll i = a; i <= b; i++)
	{
		if (moze(p, q, r, i)) br++;
	}
	return br;
}

int main()
{
	ll p, q, r,s; cin >> p >> q >> r;
	ll a, b,br=0; cin >> a >> b;
	s = nzs(p, nzs(q, r));
	if (b - a <= 7 * s) br = broj(p,q,r,a, b);
	else
	{
		if (a <= s)
		{
			br += broj(p, q, r, a, s);
			a = s + 1;
		}
		br += broj(p, q, r, a, ((a + s - 1) / s)*s);
		br += (b / s - (a + s - 1) / s)*broj(p, q, r, s + 1, 2 * s);
		br += broj(p, q, r, ((b + 1) / s)*s+1, b);
	}
	cout << br <<endl;
	system("pause");
}