#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

long long broj=0;
void binarnaPoResenju(long long n, bool nizResenja[])
{
    long long l=0, d=n-1, s;
    while(l<=d)
    {
        s=l+(d-l)/2;
        //cout<<"s: "<<s<<"\n";
        //cout<<"a[n-s]: "<<a[s]<<"\n";
        //for(int i=0; i<n; ++i)
        //cout<<"a[i]: "<<a[i]<<"\n";
        if(nizResenja[n-s])
        {
            if(s>broj)
                broj=s;
            //cout<<"broj: "<<broj<<"\n";
            l=s+1;
        }
        else
        {
            d=s-1;
        }
        //cout<<"\n\n";
    }
}
int main()
{
    iostream::sync_with_stdio(false);
    short p,q,r;
    long long L,R;
    cin>>p>>q>>r>>L>>R;
    //short resenja[R-L+1]={0};
    bool resenja[R-L+1]={false};
    for(long long i=R; i>=L; --i)
    {
        //cout<<"i: "<<i<<"\n";
        //cout<<"i/p: "<<ceil((float)i/p)<<" i/q: "<<ceil((float)i/q)
                        //<<" i/r: "<<ceil((float)i/r)<<"\n";
        float tren = ceil((float)i/p)+ceil((float)i/q)+ceil((float)i/r);
        //cout<<"Tren: "<<tren<<"\n";
        //if(((q*r+p*r+p*q)*i)<=(p*q*r)*i)
        if(tren<=i)
        {
            //resenja[R-i]=1;
            resenja[R-i]=true;
        }
        //cout<<"\n";
    }
    //for(int i=L; i<=R; ++i)
        //cout<<resenja[R-i]<<" ";
    //cout<<"\n\n";
    sort(resenja, resenja+R-L+1);
    //for(int i=L; i<=R; ++i)
        //cout<<resenja[R-i]<<" ";
    //cout<<"\n";
    binarnaPoResenju(R-L+1, resenja);
    cout<<broj<<"\n";
    return 0;
}