#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; bool rcmp(int a, int b) { return a>b; } typedef long long LL; int gw, gh, la, lb; LL ka, kb, wh; char check(LL r, LL c) { LL rc=r; rc*=la; LL cc=c; cc*=lb; if (rc>gh) rc=gh; if (cc>gw) cc=gw; rc*=cc; LL xx=wh-rc, d; rc=r*ka; cc=c*kb; xx-=rc; if (xx<=0) return 1; xx-=cc; if (xx<=0) return 1; return 0; } int main() { int n, r; int h, w; LL v, t, x, d, i, j, nj, xd; scanf("%d %d %d %d %lld %lld", &h, &w, &la, &lb, &ka, &kb); gh=h; gw=w; wh=h; wh*=w; r = h+w; for (i=0; ; i++) { if (i>r) break; if (check(i, r-i)==0) continue; d=r-i; xd=d; j=-1; while(d) { while(1) { nj=j+d; if (nj>xd) break; if (check(i, nj)) break; j=nj; } d>>=1; } j++; if (r>i+j) r=i+j; } printf("%d\n", r); return 0; }