#include <bits/stdc++.h>
#define ll long long
#define endl "\n"

//const ll N=  1000000007;

using namespace std;

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);

int p,q,r;
ll a,b;
cin >> p >> q >> r >> a >> b;
float d=1;
float k= d-d/float(p)-d/float(q)-d/float(r);

if (p*q+q*r+q*p>p*q*r) {cout<< 0; return 0;}
if (p*q+q*r+q*p==p*q*r)
{

int m=1;
int nzs=(p*q)/__gcd(p,q);
m=(nzs*r)/__gcd(nzs,r);
ll prvi=(a-1)/m;
ll drugi=b/m;
cout << drugi-prvi;
return 0;

}


ll cur = a;
ll output=0;

float l=float(cur)*k;


while (l<=4)
{

    ll cmp=cur/p+cur/q+cur/r;
    if (cur%p!=0) cmp++;
    if (cur%q!=0) cmp++;
    if (cur%r!=0) cmp++;
    if (cmp<=cur)  { output++; }

    cur++;
    if (cur>b) break;
    l=float(cur)*k;
}
output+=b+1-cur;
cout << output;

}