#include <bits/stdc++.h>

using namespace std;

int euklid(int a,int b)
{
    int r = a % b;
    if (r == 0) return b;
    euklid(b,r);
}

int NZS(int p, int q)
{
    return (p*q) / euklid(p,q);
}

int main()
{
    long long L, R;
    int p,q,r, nzs, nzd;
    scanf("%d%d%d%",&p,&q,&r);
    cin >> L >> R;
    if (p == 1 || q == 1 || r == 1)
    {
        printf("0");
    }
    else
    {
        int b = 0;
        long long u = 0;
        nzs = NZS(NZS(p,q), r);
        if ((R - L) < (2 * nzs))
        {
            for (int i = L; i <= R; i++)
            {
                if (ceil(i*1.0/p) + ceil(i*1.0/q) + ceil(i*1.0/r) <= i) u++;
                //cout << ceil(i*1.0/p) + ceil(i*1.0/q) + ceil(i*1.0/r) << " ";
            }
            //cout << endl;
        }
        else
        {
            for (int i = nzs; i < 2 * nzs; i++)
            {
                if (ceil(i*1.0/p) + ceil(i*1.0/q) + ceil(i*1.0/r) <= i) b++;
            }
            if (L%nzs != 0)
                for (long long i = L; i < (L/nzs + 1)*nzs; i++)
                {
                    if (ceil(i*1.0/p) + ceil(i*1.0/q) + ceil(i*1.0/r) <= i) u++;
                }
            if (R%(nzs-1) != 0)
                for (long long i = (R/nzs)*nzs; i <= R;i++)
                {
                    if (ceil(i*1.0/p) + ceil(i*1.0/q) + ceil(i*1.0/r) <= i) u++;
                }
                u += ( ((R/nzs)*nzs - (L/nzs + 1)*nzs) / nzs ) * b;
        }
        cout << u;
    }
    return 0;
}