#include <iostream>
#include <queue>

using namespace std;


int main()
{
    int p, q, r;
    long long lf, rg;
    cin >> p >> q >> r >> lf >> rg;
    int x;
    x = p * q * r - p * q - p * r - q * r;
    if (x < 0)
    {
        cout << 0;
    }
    else if (x >= 3)
    {
        if (lf == 1)
        {
            cout << rg - 2;
        }
        else if (lf == 2)
        {
            cout << rg - 1;
        }
        else
        {
            cout << rg;
        }
    }
    else
    {
        long long pqr = (rg / (p * q * r)) - (lf / (p * q * r));
        if (x == 0)
        {
            cout << pqr;
        }
        else
        {
            long long pq = rg / (p * q) - lf / (p * q);
            long long pr = rg / (p * r) - lf / (p * r);
            long long qr = rg / (q * r) - lf / (q * r);
            if (x == 1)
            {
                cout << pq + pr + qr - 2 * pqr;
            }
            else
            {
                long long pp = rg / p - lf / p;
                long long qq = rg / q - lf / q;
                long long rr = rg / r - lf / r;
                cout << pp + qq + rr - pq - pr - qr + pqr;
            }
        }
    }

    return 0;
}