#include <bits/stdc++.h>

using namespace std;

#define int ll
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pi> vp;
typedef vector<pl> vpl;

int h(int a, int b){
	int sol = 0;
	if (a % b && a > 0){
		++sol;
	}
	if (a % b && a < 0)
		--sol;
	sol += a / b;
	return sol;
}

//preuzeto sa https://www.geeksforgeeks.org/count-numbers-divisible-m-given-range/
int f(int A, int B, int M) { 
    // Add 1 explicitly as A is divisible by M 
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 

int nzs(int a, int b, int c){
	for (int i = 1; i <= 2000; ++i){
		if (i % a == 0 && i % b == 0 && i % c == 0)
			return i;
	}
}

signed main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr); 
	cout.tie(nullptr); 
	cerr.tie(nullptr);	

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

	vi tt = {p, q, r};
	sort(tt.begin(), tt.end());
	p = tt[0]; q = tt[1]; r = tt[2];

	int g = nzs(p, q, r);
	if (p * q * r - p * q - p * r - q * r == 0){
		//samo deljivi sa sva tri
		return cout << f(L,R,g) << '\n', 0;
	}

	if (p * q * r - p * q - p * r - q * r < 0)
		return cout << "0\n", 0;

	int sol = 0;
	for (int mp = 0; mp < p; ++mp){
		for (int mq = 0; mq < q; ++mq){
			for (int mr = 0; mr < r; ++mr){
			//	bool ok = (mp == 0 && mq == 0 && mr == 2);
				int lower = h(p*q*mr + p*r*mq + q*r*mp, p*q*r-p*r-p*q-q*r);

				int mini = -1;
				for (int i = lower; i <= lower + g + 1; ++i){
					if ((i+mp) % p == 0 && (i+mq) % q == 0 && (i+mr) % r == 0){
						mini = i;
						break;
					}
				}
				if (mini == -1) continue;

			//	if (ok)
			//		cout << lower << ' ' << mini << '\n';

				//i sad svaki g-ti od mini u segmentu [l, r]
				//k1 - najmanji nenegativan broj takav da mini + k1 * g >= L
					//sledi da je k1 >= gornji(L-mini/g)
				int k1 = max(0ll, h(L - mini, g));

				//k2 - najveci nenegativan broj takav da mini +k2 * g <= R
					//sleda da je k2 <= R - mini)/g
				int k2 = max(0ll, (R - mini) / g);

				int res = 0;
				if (k1 * g + mini >= L && k2 * g + mini <= R && k2 >= k1){
					res = k2 - k1 + 1;
				}
				//cout << res << '\n';
				sol += res;
			//	if (ok)
			//	cout << k1 << ' ' << k2  << ' ' << g<< '\n';
			}
		}
	} 

	cout << sol << '\n';
}

//pretezak je ovaj B