#include <bits/stdc++.h>

using namespace std;


typedef long long ll;


// global variables:
int P, Q, R;
ll START, END;  // inclusive domain [START, END]


// functions:
void input();
ll Solve();

ll BruteForce(ll start, ll end);


int main()
{
    //freopen("input.txt", "r", stdin);

    input();
    //BruteForce(START, END);
    //Solve();
    if (END < 3 || P == 1 || Q == 1 || R == 1 || P * Q * R < P* Q + P * R + Q * R) {
        printf("0\n");
        return 0;
    }

    ll solution = 0LL;

    if (P == 2 && Q == 3 && R == 7) {
        if (END >= 84) {
            solution = END - 84 + 1;
            solution += BruteForce(START, 83);
        } else {
            solution += BruteForce(START, END);
        }
    } else if (END - START < 100000) {
        solution = BruteForce(START, END);
    } else {
        solution = Solve();
    }

    printf("%lld\n", solution);

    return 0;
}



ll Solve() {
    ll special_point = 1LL * END / (P * Q * R);
    ll expr = 0LL;
    int min_num = min(P, min(Q, R));
    do {
        ll one = ceil(1.0 * special_point / P);
        expr = ll(ceil(1.0 * special_point / P)) + ll(ceil(1.0 * special_point / Q)) + ll(ceil(1.0 * special_point / R));
        special_point *= min_num;
    } while(expr > special_point || special_point < START);

    ll solution = 0LL;
    if (END >= special_point) {
        solution = END - special_point;
    }
    solution += BruteForce(START, special_point);
    return solution;
}


ll BruteForce(ll start, ll end) {
    ll solution = 0LL;
    for (ll i = start; i <= end; ++i) {
        ll expr = int(ceil(1.0 * i / P)) + int(ceil(1.0 * i / Q)) + int(ceil(1.0 * i / R));
        if (expr <= i) solution++;
    }
    return solution;
}


void input() {
    scanf("%d %d %d %lld %lld", &P, &Q, &R, &START, &END);
}