#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define mid(l, r) ((l)+(r))/2
#define len(a) (a).length()
#define sz(a) (a).size()
#define xx first
#define yy second
#define inf int(2e9)
#define ff(i, a, b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i, a, b) for(int (i) = (a); (i) >= (b); --(i))


using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

template<class T>
void print(const T niz[], const int siz)
{
    for(int i=0;i<siz;i++)
        cout << niz[i] << " ";
    cout << endl;
}

ll p,q,r;
ll l,ri;
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> p >> q >> r >> l >> ri;
    ll prvi = p*q + p*r + q*r;
    ll drugi = p*q*r;
    if(prvi > drugi)cout << 0 << endl;
    else if(drugi == prvi){
        ll pp = (p * q) / (__gcd(p,q));
        pp = (pp * r) / (__gcd(pp, r));
        ll res = (ri / pp) - (l - 1) / pp;
        cout << res << endl;
    }
    else{

        int res = 0;
        for(int i=1; i<=1000000; i++){
            int a,b,c;
            a = (i + p - 1) / p;
            b = (i + q - 1) / q;
            c = (i + r - 1) / r;

            if(a + b + c > i && i >= l && i <= ri)res++;
        }
        cout << ri - l - res + 1 << endl;
    }
    return 0;
}