#include <stdio.h>
#include <stdlib.h>
#include <iostream>

using namespace std;

int main()
{
    int p,q,r;

    long long int L;

    long long int R;

    scanf("%d",&p);
    scanf("%d",&q);
    scanf("%d",&r);

    scanf("%d",&L);
    scanf("%lld",&R);

    float x = float(1)/float(p);
    float y = float(1)/float(q);
    float z = float(1)/float(r);

    float n = x+y+z;

    if(n>1)
    {
        printf("%d",0);

        return 0;
    }

    int limit = p*q*r;

    long long int suma=0;
    int poc = L,kraj = R;

    if(limit < R)
    {
        suma+=R-limit;

        kraj = limit-1;
    }

    int minimum = max(max(p,q),r);

    if(L < minimum)
    {
        suma+= minimum-L;

        poc = minimum;
    }

    for(int i=poc;i<kraj+1;i++)
    {
        int k=0;

        if(i % p == 0)
            k++;

        if(i % q == 0)
            k++;

        if(i % r == 0)
            k++;

        if(k>1) suma++;
    }

    printf("%lld",suma);
}