#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) { if (kb>0&&c>=gw) return 1; LL rc=r; rc*=la; LL cc=c; cc*=lb; if (rc>gh) rc=gh; if (cc>gw) cc=gw; if (c>gw) cc=gw; if (r>gh) rc=gh; rc*=cc; LL xx=wh-rc, d; if (ka) { d = (xx+ka-1)/ka; if (d<=r) return 1; rc=r; rc*=ka; xx-=rc; if (xx<=0) return 1; } if (kb) { d=(xx+kb-1)/kb; if (d<=c) return 1; cc=c; cc*=kb; 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; x=i; x*=la; if (x>=h) x=0; else x=(h-x)*w; v=ka; v*=i;// t=kb; t*=w; t*=h; if (vxd) break; if (check(i, nj)) break; j=nj; } d>>=1; } j++; if (r>i+j) r=i+j; } printf("%d\n", r); return 0; }