#include <bits/stdc++.h>

#define endl "\n"
#define ll long long

using namespace std;

int cleil(int a, int b) {
    return (a+b-1)/b;
}

ll per236(ll A,ll B)
{
    if(A%6==0)
        return (B/6)-(A/6)+1;
    return (B/6)-(A/6);
}

ll per244(ll A,ll B)
{
    if(A%4==0)
        return (B/4)-(A/4)+1;
    return (B/4)-(A/4);
}

ll per333(ll A,ll B)
{
    if(A%3==0)
        return (B/3)-(A/3)+1;
    return (B/3)-(A/3);
}

int main()
{
    //  https://gofile.io/?c=fO4l56   mojih ruku delo

    ios_base::sync_with_stdio(false);  cin.tie(0);

    int a[3]; ll L,R;
    cin >> a[0] >> a[1] >> a[2] >> L >> R;

    sort(a,a+3);
    if(a[0]==1) {
        cout << "0" << endl;
        return 0;
    }

    //periodicni
    if(a[0]==2 && a[1]==3 && a[2]==6) {
        cout << per236(L,R) << endl;
        return 0;
    }
    if(a[0]==2 && a[1]==4 && a[2]==4) {
        cout << per244(L,R) << endl;
        return 0;
    }
    if(a[0]==3 && a[1]==3 && a[2]==3) {
        cout << per333(L,R) << endl;
        return 0;
    }

    const int lim=1500;
    int A[lim+1];

    for(int i=1;i<=lim;i++) {
        if(cleil(i,a[0])+cleil(i,a[1])+cleil(i,a[2])<=i)
            A[i]=1;
        else
            A[i]=0;
    }

    int last;
    if(cleil(10000,a[0])+cleil(10000,a[1])+cleil(10000,a[2])<=10000)
        last=1;
    else
        last=0;

    //1 - 1500

    ll ans=0;///

    if(L<=lim) {
        if(R<=lim) {
            for(int i=L;i<=R;i++) {
                if(A[i])
                    ans++;
            }
            cout << ans << endl;
            return 0;
        }
        else {
            for(int i=L;i<=lim;i++) {
                if(A[i])
                    ans++;
            }
            if(last)
                ans+=R-lim;
            cout << ans << endl;
            return 0;
        }
    }
    else {
        if(last) {
            ans=R-L+1;
            cout << ans << endl;
            return 0;
        }
        else {
            cout << "0" << endl;
            return 0;
        }
    }

    return 0;
}