#include<bits/stdc++.h>

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

int cntProsti[20];
const int MAX = 1e9;

void fakt(int x)
{
    for(int i = 2; i <= x; i++)
    {
        int br = 0;
        while(x % i == 0)
        {
            br++;
            x /= i;
            if(x == 1) break;
        }
        cntProsti[i] = max(cntProsti[i], br);
        if(x == 1) break;
    }
}

int pomnozi(int x, int cnt)
{
    int r = 1;
    while(cnt--) r *= x;
    return r;
}

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

    ll p, q, r, L, R;
    cin >> p >> q >> r >> L >> R;

    fakt(p);
    fakt(q);
    fakt(r);
    int nzs = 1;
    for(int i = 2; i <= 10; i++) nzs *= pomnozi(i, cntProsti[i]);
    //cout << nzs;

    ll br = 0;
    int Rg = 0;
    if(R > MAX) Rg = MAX;
    else Rg = R;
    int Lg = 0;
    if(L > MAX) Lg = MAX;
    else Lg = L;

    ll interval = 0;
    for(ll i = max(1, Lg); i <= min(nzs + 10, Rg); i++)
    {
        if((i+p-1)/p + (i+q-1)/q + (i+r-1)/r <= i) br++;
        if(i >= L && i <= R) interval++;
    }
    ll rez = 0;
    if(interval == 0) rez = R - L + 1;
    else
        rez = R - L + 1 - interval + br;

    cout << rez;
    /*for(int i = 1; i <= 1000; i++)
    {
        if((i+p-1)/p + (i+q-1)/q + (i+r-1)/r > i) cout << i << "\n";
    }*/


    return 0;
}