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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

	ll a, b, c, L, R;
	cin >> a >> b >> c >> L >> R;
	ll l=L, r=R, res = R+1;
	while(l <= r){
        ll mid = l + (r-l)/2;
        if(mid >= (mid+a-1)/a + (mid+b-1)/b + (mid+c-1)/c){
            res = mid;
            r = mid-1;
        }
        else l = mid+1;
	}
	cout << max(0LL, R-res+1);
    return 0;
}