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

long long int broj = 1000000;

long long int IT( long long int n, long long int k )
{
    if ( n%k == 0 )
    {
        return n/k;
    }
    return n/k+1;
}

int Jedinica( int p, int q, int r )
{
    double rez = 1.0/p+1.0/q+1.0/r;
    if ( rez == 1 )
    {
        return max( p, max( q, r ) );
    }
    return -1;
}

long long int CountDivisibles( long long int A, long long int B, int M )
{
    if ( A%M == 0 )
    {
        return ( B/M )-( A/ M)+1;
    }
    return ( B/M )-( A/M );
}

int main()
{
    int p,q,r;
    long long int L,R,o,br=0,t;

    cin >> p >> q >> r >> L >> R;
    int j = Jedinica(p,q,r);

    if ( j > 0 )
    {
        cout << CountDivisibles( L, R, j );
        return 0;
    }

    for ( long long int i = L; i <= min( broj, R ); i++ )
    {
        o = i;
        t = IT( i, p );
        if ( t < o )
        {
            o -= t;
        }
        else
        {
            continue;
        }

        t = IT( i, q );
        if ( t < o )
        {
            o -= t;
        }
        else
        {
            continue;
        }

        t = IT( i, r );
        if ( t <= o )
        {
            br++;
           continue;
        }
    }

    if ( br == 0 )
    {
        cout << 0;
        return 0;
    }
    if ( R <= broj )
    {
        cout << br << endl;
    }
    else
    {
        cout << br+(R-broj);
    }

    return 0;
}