#include<iostream>
using namespace std;

int GCD(unsigned long long a, unsigned long long b)
{
	if (a == 0)
		return b;
	if (b == 0)
		return a;
	if (a == b)
		return a;

	if (a > b)
		return GCD(b, a - b);
	return GCD(b - a, a);
}

int LCM(unsigned long long a, unsigned long long b)
{
	return (a * b) / GCD(a, b);
}

int countDel(unsigned long long a, unsigned long long b, unsigned long long m)
{
	if (a % m == 0)
		return (b / m) - (a / m) + 1;

	return (b / m) - (a / m);
}




int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	unsigned long long p, q, r, L, R;

	cin >> p >> q >> r >> L >> R;

	unsigned long long theLCM = LCM(LCM(p, q),r);
	unsigned long long theSum = theLCM / p + theLCM / q + theLCM / r;
	unsigned long long maxElements=theLCM-theSum;


	int minDel = p;
	if (q < minDel)
		minDel = q;
	if (r < minDel)
		minDel = r;


	if (R < minDel)
	{
		cout << 0;
		
	}
	else if (maxElements > 2)
	{
		if (minDel < L)
			cout << R - L + 1;
		else
		{
			cout << R - minDel + 1;
		}
	}
	else if(maxElements == 2)
	{
		unsigned long long pp,qq,rr,pq, qr, pr, pqr;
	 
		pp = countDel(L, R, p);
		qq = countDel(L, R, q);
		rr = countDel(L, R, r);
		pq = countDel(L, R, LCM(p,q));
		qr = countDel(L, R, LCM(q, r));
		pr = countDel(L, R, LCM(p, r));
		pqr = countDel(L, R, theLCM);

		cout << pp + qq + rr - pq - qr - pr + pqr;
	}
	else if (maxElements == 1)
	{
		unsigned long long pp, qq, rr, pq, qr, pr, pqr;
	
		pq = countDel(L, R, LCM(p, q));
		qr = countDel(L, R, LCM(q, r));
		pr = countDel(L, R, LCM(p, r));
		pqr = countDel(L, R, theLCM);
	
		cout <<  pq + qr + pr - pqr;
	}
	return 0;
}