#include <iostream>
#include <cmath>
using namespace std;
long long ans=1e18, n, m;
int main() {
	cin >> n >> m;
	for(long long i=1;i<n;i++){
		ans=min(ans,max(abs(i*m-m/2*(n-i)),max(((m+1)/2-m/2)*(n-i),abs(i*m-(m+1)/2*(n-i)))));
		ans=min(ans,max(abs(i*m-m*(n-i)/2),max(((n-i+1)/2-(n-i)/2)*(m),abs(i*m-(n-i+1)/2*m))));
	}
	for(long long i=1;i<m;i++){
		ans=min(ans,max(abs(i*n-n/2*(m-i)),max(((n+1)/2-n/2)*(m-i),abs(i*n-(n+1)/2*(m-i)))));
		ans=min(ans,max(abs(i*n-n*(m-i)/2),max(((m-i+1)/2-(m-i)/2)*(m),abs(i*n-(m-i+1)/2*n))));
	}
	cout << ans;
	return 0;
}