#define _CRT_SECURE_NO_WARNINGS

#define u unsigned long long int

#define caln() (ceil(n, p) + ceil(n, q) + ceil(n, r))
#define printndif printf("-%llu = n%llu - %llu = n%llu - (%llu)+(%llu)+(%llu)\n", caln() - n, n, caln(), n, ceil(n, p), ceil(n, q), ceil(n, r));
#define printdif printf("%llu = n%llu - %llu = n%llu - (%llu)+(%llu)+(%llu)\n", n - caln(), n, caln(), n, ceil(n, p), ceil(n, q), ceil(n, r));

#include <stdio.h>

#define sortswap(X,Y) if(X>Y){n=X;X=Y;Y=n;}

u
n, cnt = 0,
p, q, r, L, R;

u ceil(u X, u Y) {
	return ((X + Y - 1) / Y);
}

enum rezultat {
	jedanJedan = 2,
	jedanDva = 3,
	jedanTri = 4,
	jedanPet = 6,
	sve = 1, //2 10 10
	nista = 0 //1 1 1
};


u Apr(u LL, u RR, rezultat rez) {
	u cc = 0, n = LL, t = 0;

	if (rez == nista) return 0;
	else if (rez == sve) return (RR - LL) + 1;
	else {
		
		while ((t = caln()) > n) {
			//printf("t%llu > n%llu [%2llu %2llu %2llu](%llu %llu)\n",t,n,p,q,r,LL,RR);
			n++;
			if (n > RR)return 0;
		} //dok ne dodjemo na 'jedan' (caln() koj je <= N)
			
		//if (t <= n)
		//posto smo dosli na pozitivno/nula resenje ('jedan')
		cc++;

		//sad treba do kraja da dodjemo i izbrojimo kolko jos ima
		if (rez == jedanPet) {
			cc += (RR - n) / 6;
		}
		else if (rez == jedanTri) {
			cc += (RR - n) / 4;
		}
		else if (rez == jedanDva) {
			cc += (RR - n) / 3;
		}
		else if (rez == jedanJedan) {
			cc += (RR - n) / 2;
		}
		
	}

	return cc;
}
u Cnt(u LL, u RR) {
	u cc = 0;
	n = LL - 1;
	
	while (n++ != RR) {
		//print
		if (caln() <= n) {
			cc++;
			//printdif
		}
		else {
			//printndif
		}
	}
	return cc;
}

//#define allLR
//#define allPQR

int main() {

	p = 2; q = 3; r = 6;
	L = 108; R = 218;


	//scanf("%llu %llu %llu %llu %llu", &p, &q, &r, &L, &R);


	//sort L R
	sortswap(L, R)


	u pp=p,qq=q,rr=r;

#ifdef allLR
	for (L = 0; L < 1000; L++) for (R = 0; R < 1000; R++) { R = L + R;
#endif
#ifdef allPQR
		for (pp = 1; pp < 11; pp++) for (qq = 1; qq < 11; qq++) for (rr = 1; rr < 11; rr++){
#endif

			p = pp; q = qq; r = rr;

			//sort p q r
			sortswap(p, q)
			sortswap(p, r)
			sortswap(q, r)

#ifdef allPQR
			//skip koje smo prosli vec
			if (p < pp)continue; if (p <= pp && q < qq)continue; if (p <= pp && q <= qq && r < rr)continue;
#endif

			if ((R-L+1)>110) {

				cnt = Cnt(100, 1100);

				//printf("%llu", cnt);

				rezultat rez = nista;

				if (cnt == 0)
					rez = nista; //1 1 1
				else if (cnt == 167)
					rez = jedanPet; //2 3 6
				else if (cnt == 251)
					rez = jedanTri; //2 4 4
				else if (cnt == 333)
					rez = jedanDva; //3 3 3
				else if (cnt == 500)
					rez = jedanJedan;
				else if (cnt == 1001)
					rez = sve; //2 10 10
				else {
					printf("!! [%2llu %2llu %2llu](%llu %llu) : %llu (%d)\n", p, q, r, L, R, cnt, rez);
				}



				//calculate count
				if (L < 100)
					//get actual first 99 and approximate rest
					cnt = Cnt(L, 99) + Apr(100, R, rez);
				else
					//we dont have low (volatile) values so we are safe to approximate
					cnt = Apr(L, R, rez);

				//actually check
				if (cnt != (n = Cnt(L, R)))
					printf("\n[%2llu %2llu %2llu](%llu %llu) : %llu actual vs %llu approximate ? rez: %d\n", p, q, r, L, R, n, cnt, rez);

			} else {
				cnt = Cnt(L, R);
			}

			printf("%llu", cnt);

			//printf("\n[%2llu %2llu %2llu](%llu %llu) : %llu", p, q, r, L, R, cnt);

#ifdef allPQR
		}
#endif
#ifdef allLR
	}
#endif




	return 0;
}