#include <iostream>
using namespace std;
typedef long long ll;
typedef long double sd;
const int N = 3e6;
inline int divis(int a, int b) {
	return (a + b - 1) / b;
}
ll L, R, l, k, m;
int n, j, i, p, q, r, x;
bool a[N];

int gcd(int a, int b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

int main() {
	cin >> p >> q >> r >> L >> R;
	n = lcm(p, lcm(q, r));
	sd w = 1 / sd(p) + 1 / sd(q) + 1 / sd(r);

	if (w > 1)return cout << 0, 0;
	if (w == 1)return cout << R / n - (L - 1) / n, 0;

	i = 1;
	while (j < n) {
		x = i - (divis(i, p) + divis(i, q) + divis(i, r));
		a[i] = (x < 0);
		if (a[i])j = 0;
		else ++j;
		++i;
	}
	m = i;

	ll s = R - L + 1ll;
	for (k = L; k < m && k <= R; ++k)if (a[k])--s;
	cout << s;
}