#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int h,w;
  cin >> h >> w;
  if(h%3 == 0 || w%3 == 0){
    cout << 0 << endl;
    return 0;
  }
  vector<long long int> s(3),t(3);
  long long int cutw=(w+1)/3;
  long long int cuth=h/2;
  long long int cutha=(h+1)/3;
  long long int cutwa=w/2;
  s[0]=h*cutw;
  s[1]=h/2*(w-cutw);
  s[2]=(h-h/2)*(w-cutw);
  sort(s.begin(),s.end());
  t[0]=w*cutha;
  t[1]=w/2*(h-cutha);
  t[2]=(w-w/2)*(h-cutha);
  sort(t.begin(),t.end());
  cout << min(min(s[2]-s[0],t[2]-t[0]),min(h,w)) << endl;
}
  