#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int p, q, r;

    long long l, d, temp1, temp2, s, x, g = 0;

    cin >> p;
    cin >> q;
    cin >> r;
    cin >> l;
    cin >> d;

    temp1 = l;
    temp2 = d;

    while(l != d - 1)
    {
        s = (l + d) / 2;
        g = 0;

        if(s % p)
            g = s / p + 1;
        else
            g = s / p;


        if(s % q)
            g += s / q + 1;
        else
            g += s / q;


        if(s % r)
            g += s / r + 1;
        else
            g += s / r;

        //cout << s << " " << g << endl;

        if(g <= s)
            d = s;

        else
            l = s;
    }


    x = temp2 - s;

    g = 0;

    //cout << x << endl;

    if(s % p)
        g = s / p + 1;
    else
        g = s / p;


    if(s % q)
        g += s / q + 1;
    else
        g += s / q;


    if(s % r)
        g += s / r + 1;
    else
        g += s / r;

    if(g <= s)
        ++x;

    //cout << x << endl;
    if(s < temp2 - 30)
    {
        for(int i = s; i < s + 30; ++i)
        {
            g = 0;
            if(i % p)
                g = i / p + 1;
            else
                g = i / p;


            if(i % q)
                g += i / q + 1;
            else
                g += i / q;


            if(i % r)
                g += i / r + 1;
            else
                g += i / r;

            if(g > i)
                --x;
        }
    }
    else
    {
        for(int i = s; i <= temp2; ++i)
        {
            g = 0;

            if(i % p)
                g = i / p + 1;
            else
                g = i / p;


            if(i % q)
                g += i / q + 1;
            else
                g += i / q;


            if(i % r)
                g += i / r + 1;
            else
                g += i / r;

            if(g > i)
                --x;
        }
    }


    cout << x << endl;


    return 0;
}