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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] a = Console.ReadLine().Split();
            int p = int.Parse(a[0]);
            int q = int.Parse(a[1]);
            int r = int.Parse(a[2]);
            ulong L = ulong.Parse(a[3]);
            ulong R = ulong.Parse(a[4]);
            ulong s = 0;
            for (ulong i = L; i <= R; i++)
            {
                if (p == 1 || q == 1 || r == 1)
                    break;
                if ((p == 2 || p == 3 || p == 4) && (q == 2 || q == 3 || q == 4) && (r == 2 || r == 3 || r == 4))
                    break;
                if ((p == 2 || p == 3 || p == 5) && (q == 2 || q == 3 || q == 5) && (r == 2 || r == 3 || r == 5))
                    break;
                if ((p == 2 || p == 3 || p == 6) && (q == 2 || q == 3 || q == 6) && (r == 2 || r == 3 || r == 6))
                    s = (ulong)Math.Floor((double)R / 6) - (ulong)Math.Floor((double)L / 6);
                else
                {
                    ulong p1 = (ulong)Math.Ceiling(i / (double)p);
                    ulong q1 = (ulong)Math.Ceiling(i / (double)q);
                    ulong r1 = (ulong)Math.Ceiling(i / (double)r);
                    ulong sum = p1 + q1 + r1;
                    if (L < 50 && R < 50)
                    {
                        s = Izracunaj(R, L, p, q, r);
                        break;
                    }
                    else if (L < 50 && R > 50)
                    {
                        s = Izracunaj(50, L, p, q, r);
                        s += R - 50;
                        break;
                    }
                    else
                        s = R - L;
                }
            }
            Console.WriteLine(s);
        }
        static ulong Izracunaj(ulong R, ulong L,int p,int q,int r)
        {
            ulong co = 0;
            ulong co1 = 0;
            ulong s = 0;
            for (ulong j = 1; j <= L; j++)
            {
                ulong p1 = (ulong)Math.Ceiling(j / (double)p);
                ulong q1 = (ulong)Math.Ceiling(j / (double)q);
                ulong r1 = (ulong)Math.Ceiling(j / (double)r);
                ulong sum = p1 + q1 + r1;
                if (sum <= j)
                    co++;
            }
            for (ulong j = 1; j <= R; j++)
            {
                ulong p1 = (ulong)Math.Ceiling(j / (double)p);
                ulong q1 = (ulong)Math.Ceiling(j / (double)q);
                ulong r1 = (ulong)Math.Ceiling(j / (double)r);
                ulong sum = p1 + q1 + r1;
                if (sum <= j)
                    co1++;
            }
            return s = co1 - co;
        }
        
    }
}