#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
	ll H,W; cin>>H>>W;
  ll ans=LLONG_MAX;
	for(ll i=1;i<=H/2;i++){
    	ll half=(H-i)/2;
      	ans=min(ans,(max(i,max(half,H-i-half))-min(i,min(half,H-i-half)))*W);
      half=W/2;
      ans=min(ans,max(i*W,max((H-i)*half,(H-i)*(W-half)))-min(i*W,min((H-i)*half,(H-i)*(W-half))));
    }
  swap(H,W);
  for(ll i=1;i<=H/2;i++){
    	ll half=(H-i)/2;
      	ans=min(ans,(max(i,max(half,H-i-half))-min(i,min(half,H-i-half)))*W);
      half=W/2;
      ans=min(ans,max(i*W,max((H-i)*half,(H-i)*(W-half)))-min(i*W,min((H-i)*half,(H-i)*(W-half))));
    }
  printf("%lld",ans);
}