#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

struct point
{
	LL P, H, W, T;
	bool operator < (const point &rhs) const {
		if (T * (rhs.H * rhs.W) == rhs.T * (H * W)) return P < rhs.P;
		return T * (rhs.H * rhs.W) > rhs.T * (H * W);
	}
}A[7];

LL get(LL H1, LL W1, LL H2, LL W2)
{
	if (H2 * W1 < H1 * W2) {
		return H2 * W1 / H1 * H2;
	}
	else {
		return W2 * H1 / W1 * W2;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	A[0] = point{319, 1024,  768, 0};
	A[1] = point{419, 1024,  600, 0};
	A[2] = point{450,  960,  640, 0};
	A[3] = point{519, 2048, 1536, 0};
	A[4] = point{599, 1136,  640, 0};
	A[5] = point{600, 1280,  800, 0};
	A[6] = point{630, 1080, 1920, 0};
	LL H, W;
	while (cin >> H >> W) {
		if (!H && !W) break;
		for (int i = 0; i < 7; i++) {
			A[i].T = max(get(H, W, A[i].H, A[i].W), get(W, H, A[i].H, A[i].W));
		}
		sort(A, A + 7);
		cout << A[0].P << '\n';
	}
	return 0;
}
