#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll LCM(ll a, ll b){
return a*b/__gcd(a,b);
}
int main(){
ll p,q,r,L,R;
cin >>p>>q>>r>>L>>R;
ll lcm=LCM(p,LCM(q,r));
ll Size=R-L+1;
ll rez=0;
ll TRY=0;
for(int N=L;N<(L+lcm)&&N<=R;N++){
    //cout <<N<<" "<<rez<<endl;
    ll RHS=N-(ceil((double)N/p)+ceil((double)N/q)+ceil((double)N/r));
    ll LHS=(lcm/p+lcm/q+lcm/r)-lcm;
    ll Imax=((R-N)/lcm);///i<=s/lcm
    ll Imin=0;///i>=0

    if(Imax<Imin)continue;
    if(LHS==0){
        if(RHS>=0){rez+=(Imax-Imin+1);continue;}
        else continue;
    }

    if(RHS==0){
           // cout <<"RHS "<<N<<endl;
        if(LHS>0){rez++;continue;}
        rez+=(Imax-Imin+1);continue;
    }
    //cout <<"TRY "<<N<<endl;
   // cout <<"LHS>0&& RHS>0"<<endl;
    if(LHS>0){
        Imax=max(-1ll,min((ll)(RHS/LHS),Imax));

    }
    else{

        Imin=max(Imin,(ll)ceil((double)RHS/LHS));
    }
    rez+=max(Imax-Imin+1,0LL);
   // TRY+=max(Imax-Imin+1,0LL);

    //if(max(Imax-Imin+1,0LL)>10000000000000000)cout <<"LAAHL"<<endl;
    //rez-=(RHS<0);

}
//cout <<"TRIED: "<<TRY<<endl;
cout <<rez<<endl;
//cout <<"SALDO: "<<((rez-TRY)/5-1)*5+TRY<<endl;
}