#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
	if(b==0) return a;
	int p=b;
	b=a%b;
	a=p;
	return gcd(a,b);
}
int gcs(int x,int y)
{
	return (x*y/gcd(x,y));
}
int main()
{
	long long p,q,r,L,R;
	cin>>p>>q>>r>>L>>R;
	if(p==q and q==r)
	{
		if(p==2)
		{
			cout<<0<<endl;
			return 0;
		}
		else if(p==3)
		{
			cout<<(R-L)/3;
			return 0;
		}
		else
		{
			if(L==1) cout<<R-L-1<<endl;
			else if(L==2) cout<<R-L<<endl;
			else cout<<R-L+1;
			return 0;
		}
	}
	else if((p==q or q==r or r==p) and (p==2 or q==2))
	{
		cout<<0<<endl;
		return 0;
	}
	else
	{
		long long br=0;
		long long nzd=gcs(gcs(p,q),r)+2;
		for(int u=L;u<=min(nzd,R);u++)
		{
			if(ceil(u*1.00/p)+ceil(u*1.00/q)+ceil(u*1.00/r)<=u) br++;
		}
		if(R>=nzd)
		{
			br+=R-nzd;
		}
		cout<<br<<endl;
	}
	return 0;
}