import java.util.Scanner;

public class Lubenice {

	public static long gcd(long a,long b) 
    { 
        if (a == 0) 
            return b; 
          
        return gcd(b%a, a); 
    } 
	public static long deljiv(long a,long b) {
		if(a%b!=0)
			return 1;
		else 
			return 0;
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan=new Scanner(System.in);
		long p=scan.nextLong();
		long q=scan.nextLong();
		long r=scan.nextLong();
		long L=scan.nextLong();
		long R=scan.nextLong();
		
		long a = p * q + q * r + p * r;
		long b = p * q * r;
		if (a > b)
			System.out.println(0);
		else if(a==b) {
			long c = gcd(p, q);
			c = (p * q) / c;
			long t = gcd(c, r);
			c = (c * r) / t;
			if (L % c == 0 || R % c == 0)
				System.out.println((R-L)/c+1);
			else
				System.out.println((R-L)/c);
		}else {
			long br = (b / (b - a)+1)*2;
			if(br<L) {
				System.out.println(R-L+1);
			}else if(br>R) {
				long broj = 0;
				for(long i=L;i<R+1;i++) {
					if ((i / p + deljiv(i, p) + i / q + deljiv(i, q) + i / r + deljiv(i, r)) <= i)
						broj++;		
				}
				System.out.println(broj);
			}else {
				long broj = 0;
				for (long i = L; i < br + 1; i++) {
					if ((i / p + deljiv(i, p) + i / q + deljiv(i, q) + i / r + deljiv(i, r)) <= i)
						broj++;
				}
				broj =broj + R - br ;
				System.out.println(broj);
			}
		}
	   
	}
	}