#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef float sd;
const int N = 3e6;
inline ll divis(ll a, ll b) {
	return a / b + bool(a % b);
}
ll p, q, r, L, R, l, x, i, ost, kol, b;
int n, m, j;
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;
		else j=0;
		
		++i;
	}
	m = i;

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