#include <bits/stdc++.h>

#define ll long long
#define ld long double

using namespace std;

int gcd(int a, int b) {

    if(b == 0)
        return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {

    return a / gcd(a, b) * b;
}

ll f(ll n, int p, int q, int r) {

    return (n + p - 1) / p + (n + q - 1) / q + (n + r - 1) / r;
}

int main() {

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

    ld x = 1.0 / p + 1.0 / q + 1.0 / r;
    if(x > 1) {
        cout << 0 << endl;
        return 0;
    }

    if(x == 1) {
        int nzd = lcm(p, lcm(q, r));
        L += nzd - L % nzd;
        R -= R % nzd;

        cout << (R - L) / nzd + 1 << endl;
        return 0;
    }

    ll bound = (ll)ceil(3.0 / (1.0 - x)), ans = max(R - max(bound, L) + 1, 0LL);

    for(ll i = min(bound - 1, R); i >= L; i--)
        if(f(i, p, q, r) <= i)
            ans++;
    
    cout << ans << endl;
    return 0;
}