#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long p,q,r,L,R, broj;
    cin>>p>>q>>r>>L>>R;

    broj=p*q*r-p*q-p*r-q*r;
    if(broj<0)
    {
        cout<<0<<endl;
    }
    else if(broj>=3)
    {
        cout<<min(R-L,R-2)<<endl;
    }
    else if(broj==0)
    {
        cout<<floor(R/(p*q*r))-floor(L/(p*q*r))<<endl;
    }
    else if(broj==1)
    {
        cout<<(floor(R/(p*q))+floor(R/(p*r))+floor(R/(q*r))-2*floor(R/(p*r*q)))-(floor(L/(p*q))+floor(L/(p*r))+floor(L/(q*r))-2*floor(L/(p*r*q)))<<endl;
    }
    else//broj==2
    {
        cout<<((floor(R/p)+floor(R/q)+floor(R/r))-(floor(R/(p*q))+floor(R/(p*r))+floor(R/(q*r))-2*floor(R/(p*r*q))))-((floor(L/p)+floor(L/q)+floor(L/r))-(floor(L/(p*q))+floor(L/(p*r))+floor(L/(q*r))-2*floor(L/(p*r*q))))<<endl;
    }
    return 0;
}