using System;
class Program
{
    static void Main(string[] args)
    {
        string[] c = Console.ReadLine().Split(' ');
        long p = long.Parse(c[0]);
        long q = long.Parse(c[1]);
        long r = long.Parse(c[2]);
        long L = long.Parse(c[3]);
        long R = long.Parse(c[4]);
        long minus = 0;
        if ((1 / (double)p) + (1 / (double)q) + (1 / (double)r) > 1) Console.WriteLine("0");
        else if ((1 / (double)p) + (1 / (double)q) + (1 / (double)r) == 1)
        {
            long lmf = p * q * r;
            bool loop = true;
            for(int i = 2; i < Math.Sqrt(lmf) && loop;)
            {
                if (lmf % i == 0) lmf /= i;
                else i++;
            }
            Console.WriteLine((R - L) / lmf);
        }
        else
        {
            bool loop = true;
            for(long i=L;i<R && loop == true; i++)
            {
                if ((long)Math.Ceiling((double)i / p) + (long)Math.Ceiling((double)i / q) + (long)Math.Ceiling((double)i / r) >= i - 2)
                {
                    if ((long)Math.Ceiling((double)i / p) + (long)Math.Ceiling((double)i / q) + (long)Math.Ceiling((double)i / r) > i)
                    {
                        minus++;
                    }
                }
                else loop = false;
            }
            Console.WriteLine(R - L - minus+1);
        }
        
    }
}