#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

ll a, b, c;
ll nzs;

ll nadji(ll mod, ll L, ll R){
    //cout << "Pre " << L << " " << R << endl;
    if(L%nzs != mod){
        ll L1 = L;
        L += mod-L%nzs;
        if(L < L1) L += nzs;
    }
    if(R%nzs != mod){
        ll RR = R;
        R += mod-R%nzs;
        if(R > RR) R -= nzs;
    }
    //cout << " " << L << " " << R << " " << mod << endl;
    if(R <= 0 || L > R) return 0;
    ll L1 = (L-mod)/nzs;
    ll R1 = (R-mod)/nzs;
    ll res = R1+1;
    ll l = L1, r = R1;
    //cout << l << " " << r << endl;
    while(l <= r){
        ll mid = l + (r-l)/2;
        ll g = nzs*mid+mod;
        if(g >= (g+a-1)/a + (g+b-1)/b + (g+c-1)/c){
            res = mid;
            r = mid-1;
        }
        else l = mid+1;
    }
    //cout << R1 << " " << R1-res+1 << " " << mod << endl;
    return max(0LL, R1-res+1);
}

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    ll L2, R2;
	cin >> a >> b >> c >> L2 >> R2;
	nzs = a*b/__gcd(a, b);
	nzs = nzs*c/__gcd(nzs, c);
	ll res = 0;
	for(int i=0; i<nzs; i++){
        res += nadji(i, L2, R2);
	}
    cout << res;
    return 0;
}