#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
ll pos(ll x)
{   return max(0ll,x);  }

int main()
{
    ios_base::sync_with_stdio(false);
    ll p, q, r, L, R, x, k;
    cin >> p >> q >> r >> L >> R;
    ll ans = 0, P = p*q*r, d = p*q + q*r + p*r - P;
    for(ll i=0;i<P;i++) {
        ll right = i-((i+p-1)/p+(i+q-1)/q+(i+r-1)/r);
        ll ladd = pos(L-i-1)/P + (i<=L-1 ? 1:0);
        ll radd = pos(R-i)/P + (i<=R ? 1:0);
        if(d==0 && right>=0)
            ans += radd - ladd;
        else if(d==0) continue;
        else if(d>0 && right>=0)
            k = right/d,
            ans += min(k+1,radd) - min(k+1,ladd);
        else if(d>0) continue;
        else if(right>=0)
            ans += radd - ladd;
        else k = abs(right)/abs(d),
            ans += max(0ll,radd-k-1) - max(0ll,ladd-k-1);
    }
    cout << ans << endl;
    return 0;
}