using System;

namespace drugelubenice
{
    class Program
    {
        static long Zadatak(int a, int b, int c, double left, double right)
        {
            if (left > right)
                return 0;
            if (a == 2 && b == 3 && c == 7 && (left % 42 == 0))
                return 1 + Zadatak(a, b, c, left + 1, right);
            if ((Math.Ceiling((double)left / a) + Math.Ceiling((double)left / b) + Math.Ceiling((double)left / c)) <= left)
                return 1 + Zadatak(a, b, c, left + 1, right);
            return 0 + Zadatak(a, b, c, left + 1, right);

        }

		static void Zadatak1 ()
		{
			string s = Console.ReadLine();
			int sp = s.IndexOf(" ");
			int oof = int.Parse(s.Substring(0, sp));
			s = s.Remove(0, sp + 1);
			sp = s.IndexOf(" ");
			int lel = int.Parse(s.Substring(0, sp));
			s = s.Remove(0, sp + 1);
			sp = s.IndexOf(" ");
			int n = int.Parse(s.Substring(0, sp));
			s = s.Remove(0, sp + 1);
			sp = s.IndexOf(" ");
			double left = Double.Parse(s.Substring(0, sp));
			double right = Double.Parse(s.Substring(sp + 1));

			long res = Zadatak(oof, lel, n, left, right);
			Console.WriteLine(res);
		}
        static void Main(string[] args)
        {
			Zadatak1();
        }
    }
}