#include<bits/stdc++.h>
long long s,w,h,i,a,b,c,d,e,ans=1e10;
using namespace std;
int main()
{
	cin>>w>>h;
	for(i=0;i<=h/2;i++)
	{
		a=w*i;
		b=(h-i)*(w/2);
		c=w*h-a-b;
		s=max(max(a,b),c)-min(min(a,b),c);
		ans=min(ans,s);
		d=(h-i)/2*w;
		e=w*h-a-d;
		s=max(max(a,d),e)-min(min(a,d),e);
		ans=min(ans,s);
	}
	for(i=0;i<=w/2;i++)
	{
		a=h*i;
		b=(w-i)*(h/2);
		c=w*h-a-b;
		s=max(max(a,b),c)-min(min(a,b),c);
		ans=min(ans,s);
		d=(w-i)/2*h;
		e=w*h-a-d;
		s=max(max(a,d),e)-min(min(a,d),e);
		ans=min(ans,s);
	}
	cout<<ans<<endl;
	return 0;
}