#include<bits/stdc++.h>
#define PRINT(x) cerr<<#x<<'='<<x<<endl;
#define NL(x) " \n"[(x)]
#define lld long long
#define pil pair<int,lld>
#define pli pair<lld,int>
#define pll pair<lld,lld>
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mid (l+r)/2
#define endl '\n'
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF 1000000000000000LL
#define INF 1000000000
#define EPS 1e-9
using namespace std;
lld f(lld N, lld p) {
    if(N%p == 0) return N/p;
    else return N/p+1;
}

int main() {
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0);
    lld p, q, r, L, R; cin >> p >> q >> r >> L >> R;
    lld br = p*q + p*r + q*r, im = p*q*r, lcm = (p*q)/__gcd(p, q);
    lcm = lcm*r/__gcd(lcm, r);
    if(br > im) cout << 0 << endl;
    else if(br == im) cout << R/lcm - (L-1)/lcm << endl;
    else {
        lld rez = 0;
        for(lld N = L; N <= min(R,5000LL); N++) {
            if(f(N, p)+f(N, q)+f(N, r) <= N) rez++;
        }
        if(R > 5000) rez += R-max(L, 5000LL);
        cout << rez << endl;
    }
    return 0;
}