#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

int main()
{
    int p, q, r;
    ll L, R;

    cin >> p >> q >> r >> L >> R;
    //scanf("%d %d %d %lld %lld", &p, &q, &r, &L, &R);

    long double izraz = 1 - (long double)1 / p - (long double)1 / q - (long double)1 / r;

    if((p == 3 && q == 3) && r == 3)
    {
        ll brojClanova = R - L + (long long)1;

        if(brojClanova < 3)
        {
            if(brojClanova == 1)
            {
                if(L % 3 == 0)
                {
                    printf("1\n");
                }

                else
                {
                    printf("0\n");
                }
            }

            else
            {
                if(L % 3 == 0 || R % 3 == 0)
                {
                    printf("1\n");
                }

                else
                {
                    printf("0\n");
                }
            }

            return 0;
        }

        R -= (long long)(R % 3);

        ll resenje = brojClanova / (long long)3;

        if(L % 3 == 0)
        {
            resenje++;
        }

        printf("%lld\n", resenje);
    }

    else if(izraz < 0)
    {
        printf("0\n");
        return 0;
    }

    else
    {
        long double drugiIzraz = 3 / izraz;

        ll brojac = 0;

        bool daLiCeDodati = (drugiIzraz < R);

        for(ll i = L; i <= ((drugiIzraz < R) ? (drugiIzraz) : (R)); i++)
        {
            //cout << ceil(i / p) << " " << ceil(i / q) << " " << ceil(i / r) << endl;
            ll trenutniIzraz = ceil((long double)i / p) + ceil((long double)i / q) + ceil((long double)i / r);

            if(trenutniIzraz <= i)brojac++;
        }

        if(daLiCeDodati == true)
        {
            brojac += R - ((ceil(drugiIzraz) < L) ? (L) : (ceil(drugiIzraz))) + 1;
        }

        printf("%lld\n", brojac);
    }

    return 0;
}