#include <iostream>
#include <cmath>
using namespace std;

long long NZD(long long x, long long y) {
    if (x % y == 0)
        return y;
    return NZD (y, x % y);
}

long long NZS (long long x, long long y) {
    return (x * y) / NZD(x, y);
}

int main()
{
    long long p, q, r, L, R;
    cin >> p >> q >> r >> L >> R;
    double x = 1.0 / p + 1.0 / q + 1.0 / r;
    if (x > 1) {
        cout << 0;
        return 0;
    }
    if (x == 1) {
        long long max1 = NZS(NZS(p, q), r);
        cout << (R - L + L % max1) / max1 + (L % max1 == 0?1:0);
        return 0;
    }
    long long max1 = NZS(NZS(p, q), r);
    long long s = max1 / p + max1 / q + max1 / r;
    long long S = ceil(max1 / (max1 - s)) * max1;
    long long resenje = 0;
    for (long long i = L; i < S && i <= R; i++) {
        if (ceil(i * 1.0/ p) + ceil(i * 1.0/ q) + ceil(i * 1.0/ r) <= i)
            resenje++;
    }
    resenje += (R - S + 1) > 0? (R - S + 1) : 0;
    cout << resenje;
    return 0;
}