#include <bits/stdc++.h>
#define pb push_back
#define mid(l, r) ((l)+(r))/2
#define len(a) (a).length()
#define sz(a) (a).size()
#define xx first
#define yy second
#define ll long long 			//-+ 9,223,372,036,854,775,807  = 9.2*10^18 = 2^63 - 1
#define ull unsigned long long	// +18,446,744,073,709,551,615  = 1.8*10^19 = 2^64 - 1
#define l long					//-+ 			 2,147,483,647	= 2.1*10^9  = 2^31 - 1
#define ul unisgned long		// +			 4,294,967,295	= 4.3*10^9	= 2^32 - 1
#define db double
#define ldb long double
#define ff(i,n) for(int (i) = 0; i < (n); ++i)
#define fff(i,a,b) for(int (i) = (a); (i)<=(b); ++i)
#define ffb(i,a,b) for(int (i) = a; i >= b; --i)

using namespace std;
long long gcd(long long a, long long b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
long long lcm(long long a, long long b)  
 {  
    return (a*b)/gcd(a, b);  
 }  

ll prov(ll a, ll b){
	ll rez=0;
	if (a%b!=0){
		rez=a/b + 1;
	}
	else rez=a/b;
	return rez;
	
}

int main(){
	
    ios::sync_with_stdio(0);
    cin.tie(0);
    const int LIM=0;

    ll i=0,j=0,k=0,a=0,b=0,n=0,t=1,x=0,le=0,re=0;
    ll p=0, q=0, r=0;
    ll  sol=0,ans=0,rez=0;
	
	cin >> p >> q >> r >> le >> re;
	
	float faktor=(1/(float)p + 1/(float)q + 1/(float)r);

	ll dist = re-le+1;
	
	if(faktor==1){
		ll ukupno=0;
		ll oduzimam=0;
		ll svaki = lcm(lcm(p,q),r);
	
		if(re%svaki==0){
			ukupno=re/svaki;
		}
		else{
			ukupno=floor((float)re/svaki);
		}
		if(le%svaki==0){
			oduzimam=le/svaki - 1;
		}
		else{
			oduzimam=floor((float)le/svaki);
		}
		cout<<ukupno-oduzimam;
		
		
	}
	else if(faktor>1){
		cout<<0;
	}
	else if(faktor<1){
		ll milion=1000000;
		ll koliko=min(dist,milion);
		fff(i,le,le+koliko-1){
		//	cout<<"je: "<<prov(i,p)<<prov(i,q)<<prov(i,r)<<endl;
			if(((prov(i,p)+prov(i,q)+prov(i,r)))<=i){
				ans++;
				
			}
		}
		if(dist>(1000000)){
			ans=ans+(dist-1000000);
		}
			cout<<ans;
	}

	
	







	return 0;
}