#include <bits/stdc++.h>

using namespace std;

long long zaokruzi(long long br,int p)
{
    return (br+p-1)/p;
}

int NZD(int p, int q)
{
    //cout<<"uso2"<<endl;
    int ret = p%q;
    if(ret == 0) return q;
    else return NZD(q,ret);
}

int NZS(int p,int q)
{
    int ret = 0;
    int pom = NZD(p,q);
    if(pom>p)  ret = (pom/p)*q;
    else ret = p*q/pom;

    return ret;
}

bool moze(long long N,int p,int q, int r)
{
    long long a,b,c;
    a = zaokruzi(N,p); b = zaokruzi(N,q); c = zaokruzi(N,r);
    //cout<<N<<" --> "<<a+b+c<<endl;
    if(a+b+c <= N) return true;
    return false;
}

long long brute_force(int p,int q,int r,long long L,long long R)
{
    long long ret = 0;
    for(long long i = L; i <= R; i++)
    {
        if(moze(i,p,q,r)) {ret++;} //cout <<"--> "<<i<<endl;}
        else
        {
            /*long long a,b,c;
            a = zaokruzi(i,p); b = zaokruzi(i,q); c = zaokruzi(i,r);
            cout<<i<<" --> "<<a+b+c<<endl;*/
        }
    }
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int p,q,r;
    long long L,R;
    cin>>p>>q>>r>>L>>R;

    long long resenje = 0;
    double odnos = (double)(p*q+p*r+q*r)/(p*q*r);
    int nzs = NZS(p,NZS(q,r));
    /*cout<<"odnos: "<<odnos<<endl;
    cout<<"nzs: "<<nzs<<endl;*/

    if(odnos == 1)
    {
        long long pocetak = L+(nzs-(L%nzs));
        long long kraj = R-(R%nzs);
        //cout<<"pocetak i kraj: "<<pocetak<<" "<<kraj<<endl;
        resenje = ((kraj - pocetak)/nzs)+1;
    }
    else if(odnos < 1)
    {
        if(L < nzs+15)
        {
            if(R > nzs) /// probaj kad je jednako nzs
            {
                for(long long i = L; i<= nzs+15; i++)
                if(moze(i,p,q,r)) resenje++;
                //cout<<"resenje posle for: "<<resenje<<endl;
                int pom = nzs+16;
                resenje = resenje + (R - pom)+1;
                //cout<<"resenje: "<<resenje<<endl;
            }
            else
            {
                for(long long i = L; i<= R; i++)
                if(moze(i,p,q,r)) resenje++;
            }
        }
    }

    cout<<resenje;
    /*long long br_resenje = brute_force(p,q,r,L,R);
    cout<<endl<<br_resenje;*/

    /*while(true)
    {
        long long a; cin>> a;
        int p; cin>>p;
        cout<<"--> "<<a<<" => "<<zaokruzi(a,p)<<endl;
    }*/
    return 0;
}