#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

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

    int lastRes = 3;
    int res = 3;
    int current = 2;

    while(res - lastRes != 3)
    {
        lastRes = res;
        int a = (current + p - 1) / p;
        int b = (current + q - 1) / q;
        int c = (current + r - 1) / r;
        res = a + b + c;
        current++;
    }

    if(((p*r + p*q + q*r) / (p * q * r) == 1 && (p*r + p*q + q*r) % (p * q * r) != 0) || ((p*r + p*q + q*r) / (p * q * r) > 1))
    {
        cout << "0" << endl;
    }
    else if((p*r + p*q + q*r) / (p * q * r) == 1 && (p*r + p*q + q*r) % (p * q * r) == 0)
    {
        cout << (R / (current - 2)) - ((L - 1) / (current - 2)) << endl;
    }
    else
    {
        ll count = 0;
        for(ll i = L; i <= R && i <= current; i++)
        {
            int a = (i + p - 1) / p;
            int b = (i + q - 1) / q;
            int c = (i + r - 1) / r;
            res = a + b + c;

            if(res <= i)
            {
                count++;
            }
        }

        if(R > current)
        {
            count += R - (L > current ? L - 1 : current);
        }


        cout << count << endl;
    }

    return 0;
}