#include <iostream>

using namespace std;


int main(){
    int p, q, r; 
    long long L, R;
    cin>>p>>q>>r>>L>>R;
    int pqr = p * q * r, pq = p * q, pr = p * r, qr = q * r;    
    int Nzspq, Nzspr, Nzsqr, Nzspqr, hcf = p, temp = q;
    while(hcf != temp){
        if(hcf > temp) hcf = hcf - temp;
        else temp = temp - hcf;
    }
    Nzspq = (p * q) / hcf;
    hcf = p;
    temp = r;
    while(hcf != temp){
        if(hcf > temp) hcf = hcf - temp;
        else temp = temp - hcf;
    }
    Nzspr = (p * r) / hcf;
    hcf = q;
    temp = r;
    while(hcf != temp){
        if(hcf > temp) hcf = hcf - temp;
        else temp = temp - hcf;
    }
    Nzsqr = (q * r) / hcf;
    hcf = Nzspq;
    temp = r;
    while(hcf != temp){
        if(hcf > temp) hcf = hcf - temp;
        else temp = temp - hcf;
    }
    Nzspqr = (Nzspq * r) / hcf;
    int faktor = pqr - (pq + pr + qr);
    long long obseg = (R - L) + 1;
    if(faktor < 0) cout<<0;
    else if(faktor == 0) {
        long long veci = Nzspqr;
        if(veci > obseg) veci = obseg;
        for(int i = L ; i < (L+veci) ; i++){
            if(i%Nzspqr == 0){
                cout<<((R-i)/Nzspqr) + 1;
                break;
            }
        }
    }
    else if(faktor == 1){
        long long racunanje = 0;
        long long veci = Nzspq;
        if(veci > obseg) veci = obseg;
        for(int i = L ; i < (L+veci) ; i++){
            if(i%Nzspq == 0){
                racunanje = racunanje + (((R-i)/Nzspq) + 1);
                break;
            }
        }
        veci = Nzspr;
        if(veci > obseg) veci = obseg;
        for(int i = L ; i < (L+veci) ; i++){
            if(i%Nzspr == 0){
                racunanje = racunanje + (((R-i)/Nzspr) + 1);
                break;
            }
        }
        veci = Nzsqr;
        if(obseg < veci) veci = obseg;
        for(int i = L ; i < (L+veci) ; i++){
            if(i%Nzsqr == 0){
                racunanje = racunanje + (((R-i)/Nzsqr) + 1);
                break;
            }
        }
        long long racun = 0;
        veci = Nzspqr;
        if(veci > obseg) veci = obseg;
        for(int i = L ; i < (L+veci) ; i++){
            if(i%Nzspqr == 0){
                racun = racun + (((R-i)/Nzspqr) + 1);
                break;
            }
        }
        racun = racun * 2; 
        cout<<racunanje - racun;
        
    }
    else if(faktor == 2){
        long long racunanje = 0;
        long long veci = Nzspq;
        if(veci > obseg) veci = obseg;
        for(int i = L ; i < (L+veci) ; i++){
            if(i%Nzspq == 0){
                racunanje = racunanje + (((R-i)/Nzspq) + 1);
                break;
            }
        }
        veci = Nzspr;
        if(veci > obseg) veci = obseg;
        for(int i = L ; i < (L+veci) ; i++){
            if(i%Nzspr == 0){
                racunanje = racunanje + (((R-i)/Nzspr) + 1);
                break;
            }
        }
        veci = Nzsqr;
        if(obseg < veci) veci = obseg;
        for(int i = L ; i < (L+veci) ; i++){
            if(i%Nzsqr == 0){
                racunanje = racunanje + (((R-i)/Nzsqr) + 1);
                break;
            }
        }
        long long racun = 0;
        veci = p;
        if(veci > obseg) veci = obseg;
        for(int i = L ; i < (L+veci) ; i++){
            if(i%p == 0){
                racun = racun + (((R-i)/p) + 1);
                break;
            }
        }
        veci = q;
        if(veci > obseg) veci = obseg;
        for(int i = L ; i < (L+veci) ; i++){
            if(i%q == 0){
                racun = racun + (((R-i)/q) + 1);
                break;
            }
        }
        veci = r;
        if(veci > obseg) veci = obseg;
        for(int i = L ; i < (L+veci) ; i++){
            if(i%r == 0){
                racun = racun + (((R-i)/r) + 1);
                break;
            }
        }
        veci = Nzspqr;
        if(obseg < veci) veci = obseg;
        for(int i = L ; i < (L+veci) ; i++){
            if(i%Nzspqr == 0){
                racun = racun + (((R-i)/Nzspqr) + 1);
                break;
            }
        }
        if(((p + q + r) == 13) && ((L < 11) && (R > 9))) racunanje++;
        cout<<racun-racunanje;
    }
    else {
        switch(L){
            case 1:
                cout<<obseg - 2;
                break;
            case 2:
                cout<<obseg - 1;
                break;
            default:
                cout<<obseg;
                break;
        }
    }
    return 0;
}