#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll L,R,p,q,r;
ll L1,R1;
ll sol=0;

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

ll solve()
{
    sol=0;
    if(p*q+p*r+q*r>p*q*r)
    {
        return 0;
    }
    if(p*q+p*r+q*r==p*q*r)
    {
        ll maxi=max(p,max(q,r));
        while((L%maxi)!=0)
            L++;
        if(L>R)
        {
            return 0;
        }
        return ((R-L)/maxi+1);
    }
    for(ll i=L;i<=R && i<=4000;i++)
    {
        if(racunaj(i)<=i)
            sol++;
    }
    if(R<=4000)
    {
        return sol;
    }
    sol+=(R-4000);
    return sol;
}


ll bruteForce()
{
    ll ret=0;
    while(L1<=R1)
    {
        if(racunaj(L1)<=L1)
            ret++;
        L1++;
    }
    return ret;
}

int proveri(int n)
{
    while(n--)
    {
        int t=50;
        while(t--)
            p=rand();
        p=rand()%10+1;
        q=rand()%10+1;
        r=rand()%10+1;
        L=rand()%100+1;
        R=L+ rand()%10000;
        L1=L;R1=R;
        ll s=solve();
        ll b=bruteForce();
        if(s!=b)
        {
            cout<<p<<" "<<q<<" "<<r<<endl;
            cout<<L<<" "<<R<<endl;
            cout<<s<<" "<<b<<endl;
            return 99;
        }
    }
    return 0;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin>>p>>q>>r>>L>>R;
	L1=L;
	R1=R;

	//cout<<proveri(10000)<<endl;
	cout<<solve()<<endl;

	return 0;
}