using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Drugi_Zadatak
{
    class Program
    {
        static ulong Vise(byte p,byte q,byte r,ulong L,ulong R)
        {
            int Razlika;
            ulong Izlaz = 0;
            ulong interval = (ulong)(p * q * r), T = (ulong)(Math.Floor((double)L / interval) + 1) * interval;
            Izlaz += (ulong)Broji(p, q, r, L, T);
            L = T;
            T = (ulong)Math.Floor((double)R / interval) * interval;
            Izlaz += (ulong)Broji(p, q, r, T, R+1);
            R = T;
            Razlika = (int)((long)L - Math.Ceiling((double)L / p) - Math.Ceiling((double)L / q) - Math.Ceiling((double)L / r));
            while (true)
            {
                if (Razlika == 0)
                {
                    int k=Broji(p,q,r,L,L+interval);
                    Izlaz += (ulong)k * (R - L) / interval;
                    return Izlaz;
                }
                if (Razlika < 0) return Izlaz;
                if (Razlika > 2)
                {
                    Izlaz += R - L;
                    return Izlaz;
                }
                Izlaz += (ulong)Broji(p, q, r, L, L + interval);
                L += interval;
            }
        }
        static int Broji(byte p, byte q, byte r, ulong L, ulong R)
        {
            int T = 0;
            for (ulong i = L; i < R; i++)
            {
                if (i >= Math.Ceiling((double)i / p) + Math.Ceiling((double)i / q) + Math.Ceiling((double)i / r)) T++;
            }
            return T;
        }
        static void Main()
        {
            string[] s = Console.ReadLine().Split(' ');
            byte p = Convert.ToByte(s[0]), q = Convert.ToByte(s[1]), r = Convert.ToByte(s[2]);
            ulong L = Convert.ToUInt64(s[3]), R = Convert.ToUInt64(s[4]), brojResenja;
            ushort interval = (ushort)(p * q * r);
            ulong brojIntervala = (ulong)(Math.Ceiling((double)R / interval) - Math.Ceiling((double)L / interval));
            if (brojIntervala > 0) brojResenja = Vise(p,q,r,L,R);
            else brojResenja = (ulong)Broji(p,q,r,L,R+1);
            Console.WriteLine(brojResenja);
        }
    }
}