#include <bits/stdc++.h>

using namespace std;
int toCel(int x,int a)
{
    if(x%a==0)
        return 0;
    return a-x%a;
}


int main()
{
    long long p,q,r,L,R,res=0,l1,r1;
    cin>>p>>q>>r>>L>>R;
    --L;
    long long nzs=p*(q*r/__gcd(q,r))/__gcd(p,q*r/__gcd(q,r));
    if(p*q+p*r+r*q==p*q*r){
        cout<<R/nzs-(L-1)/nzs<<endl;
        return 0;
    }
    if(p*q+p*r+r*q>p*q*r){
        cout<<0<<endl;
        return 0;
    }
    long long x=p*q*r-p*q-p*r-r*q;

    for(int i=1;i<nzs;i++){
        long long a=toCel(i,r)*p*q+toCel(i,q)*p*r+toCel(i,p)*r*q;
        a=(a+x-1)/x;
        l1=(max(L,a-1)+nzs-i)/(nzs);
        r1=(R+nzs-i)/(nzs);
        res+=max((long long)0,r1-l1);

    }
    res+=max((long long)0,R/(nzs)-L/(nzs));
    cout << res << endl;
    return 0;
}