#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){
		cout << (R / (p * q) + R / (p * r) + R / (q * r)) - (L / (p * q) + L / (p * r) + L / (q * r)) << endl;
	} else {
		if(L <= 2) cout << R - 2 << endl;
		else cout << R - L << endl;
	}
	return 0;
}