#include <cstdio>
#include <iostream>
#include <fstream>
#include <set>

using namespace std;

int main() {
    ifstream in("space.in");
    ofstream out("space.out");
    long long n, a, b, w, h;

    in >> n >> a >> b >> w >> h;

    long long l = -1, r = (long long)0.5e18 + 1;
    while (l < r - 1) {
        long long d = (l + r) / 2;
        // long long cnt1 = (w / (a + 2 * d)) * (h / (b + 2 * d));
        // long long cnt2 = (h / (a + 2 * d)) * (w / (b + 2 * d));
        double cnt1d = (w / (a + 2 * d)) * 1.0 * (h / (b + 2 * d));
        double cnt2d = (h / (a + 2 * d)) * 1.0 * (w / (b + 2 * d));

        if (max(cnt1d, cnt2d) >= n) l = d;
        else r = d;
    }
    out << l;
    return 0;
}
