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