#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define xx first
#define yy second
#define srt(a) sort(a.begin(),a.end());
#define srtg(a,int) sort(a.begin(),a.end(),greater<int>())
#define lb(a,x) lower_bound(a.begin(),a.end(),x)
#define up(a,x) upper_bound(a.begin(),a.end(),x)
#define fnd(a,x) find(a.begin(),a.end(),x)
#define vstart auto startt=chrono::system_clock::now()
#define vend auto endd=chrono::system_clock::now()
#define vvreme chrono::duration<double> vremee=endd-startt
#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define sta(a) R/(a)-(L-1)/(a)
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef string str;
int main()
{
    ios;
    ll p,q,r,L,R;
    cin>>p>>q>>r>>L>>R;
    L=max(L,(ll)3);
    if(p*q+p*r+r*q<=p*q*r-3){
        cout<<R-L+1;
    }else if(p*q+p*r+r*q<=p*q*r-2){
        ll res=sta(p)+sta(q)+sta(r);
        res-=sta(p/__gcd(p,q)*q);
        res-=sta(p/__gcd(p,r)*r);
        res-=sta(q/__gcd(r,q)*r);
        ll nzs=p/__gcd(p,q)*q;
        nzs=nzs/__gcd(nzs,r)*r;
        res+=sta(nzs);
        cout<<res;
    }else if(p*q+p*r+r*q<=p*q*r-1){
        ll res=sta(p/__gcd(p,q)*q);
      //  cout<<res<<"\n";
        res+=sta(p/__gcd(p,r)*r);
      //  cout<<res<<"\n";
        res+=sta(q/__gcd(r,q)*r);
      //  cout<<res<<"\n";
        ll nzs=p/__gcd(p,q)*q;
        nzs=nzs/__gcd(nzs,r)*r;
        res-=2*sta(nzs);
     //   cout<<res<<"\n";
        cout<<res;
    }else if(p*q+p*r+q*r<=p*q*r){
        ll nzs=p/__gcd(p,q)*q;
        nzs=nzs/__gcd(nzs,r)*r;
        ll res=R/nzs-(L-1)/nzs;
        cout<<res;
    }else{
        cout<<0;
    }
    return 0;
}