#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main(void){
	long long int h, w;

	cin >> h >> w;

	long long int m = 1e9;


	for (int i = 1; i < h; i++){
		m = min(m, max(w/2*i, max((w-w/2)*i, w*(h-i))) - min(w/2*i, min((w-w/2)*i, w*(h-i))));
	}

	for (int i = 1; i < w; i++){
		m = min(m, max(h/2*i, max((h-h/2)*i, h*(w-i))) - min(h/2*i, min((h-h/2)*i, h*(w-i))));
	}

	if (h % 3 == 0 || w % 3 == 0)
		m = 0;
	
	m = min(m, min(h, w));

	cout << m << endl;


}