#include <iostream>
#define endl '\n'
#define print(x) cout << x << endl;
#define max(a, b)  (((a) > (b)) ? (a) : (b))
#define min(a, b)  (((a) < (b)) ? (a) : (b))
#define ceil(a, b) ((((a)%(b)) == 0) ? ((a)/(b)) : (((a)/(b))+1))
#define debug(x) cout << #x << " = " << x << endl;
using std::cin;
using std::cout;

long long p, q, r, left, right;

bool found(int* arr, int val, int len)
{
	for (int i = 0; i < len; i++)
		if (arr[i] == val) return 1;
	return 0;
}

long long f()
{
	long long prod = p * r * q;
	if (prod/p + prod/q + prod/r > prod)
		return 0;
	long long ret = 0;
	if (p == 2 && q == 3 && r == 7)
	{
		int c[] = { 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 13, 15, 16, 17, 19, 22, 23, 25, 29, 31, 37, 43 };
		for (int i = left; i <= min(right, 43); i++)
			if (found(c, i, 22))
				ret++;
		return right - left +1- ret;
	}
	int sw = p * 100 + q * 10 + r;
	if (sw == 236)
	{
		long long l = left + (left % 6);
		long long r = right - (right % 6);
		if (r < l) return 0;
		return (r - l) / 6 + 1;
	}
	else if (sw == 238)
	{
		int c[] = { 1, 2, 3, 4, 5, 7, 9, 10, 11, 13, 17, 19, 25 };
		for (int i = left; i <= min(right,25); i++) if (found(c, i, 13)) ret++;
	}
	else if (sw == 239)
	{
		int c[] = { 1, 2, 3, 4, 5, 7, 10, 11, 13, 19 };
		for (int i = left; i <= min(right, 19); i++) if (found(c, i, 10)) ret++;
	}
	else if (sw == 245)
	{
		int c[] = { 1, 2, 3, 5, 6, 7, 9, 11, 13, 17, 21 };
		for (int i = left; i <= min(right, 21); i++) if (found(c, i, 11)) ret++;
	}
	else if (sw == 246)
	{
		int c[] = { 1, 2, 3, 5, 7, 9, 13 };
		for (int i = left; i <= min(right, 13); i++) if (found(c, i, 7)) ret++;
	}
	else if (sw == 247 || sw == 248)
	{
		int c[] = { 1, 2, 3, 5, 9 };
		for (int i = left; i <= min(right, 9); i++) if (found(c, i, 5)) ret++;
	}
	else if (sw == 249)
	{
		int c[] = { 1, 2, 3, 5 };
		for (int i = left; i <= min(right, 5); i++) if (found(c, i, 4)) ret++;
	}
	else if (sw == 256)
	{
		int c[] = { 1, 2, 3, 7 };
		for (int i = left; i <= min(right, 7); i++) if (found(c, i, 4)) ret++;
	}
	else if (sw == 257 || sw == 258 || sw == 259 || sw == 267 || sw == 268 || sw == 269 || sw == 278 || sw == 279 || sw == 289)
	{
		int c[] = { 1, 2, 3 };
		for (int i = left; i <= min(right, 3); i++) if (found(c, i, 3)) ret++;
	}
	else
	{
		int c[] = { 1, 2 };
		for (int i = left; i <= min(right, 2); i++) if (found(c, i, 2)) ret++;
	}
	return right - left + 1 - ret;
	long long rb = prod;
	int cant[1024] = { 1, 2 }, cant_sz = 2;
	if (p * q % r == 0) rb = p * q + 1;
	if (p * r % q == 0) rb = min(rb, p * r + 1);
	if (q * r % p == 0) rb = min(rb, q * r + 1);

}

void swap(long long& a, long long& b)
{
	int c = a;
	a = b;
	b = c;
}

int main()
{
	cin >> p >> q >> r >> left >> right;
	long long arr[] = { p, q, r };
	if (arr[0] > arr[1]) swap(arr[0], arr[1]);
	if (arr[1] > arr[2]) swap(arr[1], arr[2]);
	if (arr[0] > arr[2]) swap(arr[0], arr[2]);
	if (arr[0] > arr[1]) swap(arr[0], arr[1]);
	if (arr[1] > arr[2]) swap(arr[1], arr[2]);
	if (arr[0] > arr[2]) swap(arr[0], arr[2]);
	p = arr[0], q = arr[1], r = arr[2];
	cout << f();
}