#include #include #include #include #include #include using namespace std; const int MAX = INT_MAX; int test(int m, int n, int a, int b, int x, int y) { int X = m * a; int Y = n * b; int type = 0; if (X > x || Y > y) type = -1; if (type >= 0 && X == x) { type += 1; } if (type >= 0 && Y == y) { type += 2; } //printf("%d %d %d %d %d %d %d\n", m, n, a, b, x, y, type); return type; } int cost(int m, int n, int type) { int cost; switch(type) { case 0: cost = 2; break; case 2: cost = 1; break; case 1: cost = 1; break; case 3: cost = 0; break; default: cost = MAX; return cost; } cost += m * n - 1; //printf ("cost = %d\n", cost); return cost; } int main() { int m, n, a, b, x, y; for (;;) { scanf("%d%d%d%d%d%d", &m, &n, &a, &b, &x, &y); if (m == 0) break; int best = MAX; best = min(best, cost(m, n, test(m, n, a, b, x, y))); best = min(best, cost(m, n, test(m, n, b, a, x, y))); best = min(best, cost(n, m, test(n, m, a, b, x, y))); best = min(best, cost(n, m, test(n, m, b, a, x, y))); if (best == MAX) { printf("The paper is too small.\n"); } else { printf("The minimum number of cuts is %d.\n", best); } } return 0; }