#include<bits/stdc++.h>
using namespace std;

#define ll long long

int main(){
	ll p, q, r, L ,R; cin >> p >> q >> r >> L >> R;
	if(p == 2 || q == 2 || r == 2){
		ll d1 = p * q;
		ll d2 = p * r;
		ll d3 = q * r;
		ll dL = L / d1 + L / d2 + L / d3;
		ll dR = R / d1 + R / d2 + R / d3;
		cout << dR - dL << endl;
	} else {
		if(L <= 2) cout << R - 2 << endl;
		else cout << R - L << endl;
	}
	return 0;
}