import std.stdio, std.string, std.algorithm, std.conv, std.array, std.math;

void main(){
  auto hw=readln.split.to!(long[]);
  auto h=hw[0], w=hw[1];
  if(h % 3 == 0 || w % 3 == 0){
    writeln(0);
    return;
  }
  writeln(min(VtHr(h, w), HrVt(h, w), h, w));
}

long VtHr(long h, long w){
  return HrVt(w, h);

}

auto HrVt(long h, long w){
  return min(TCut(h, w, h/3), TCut(h, w, h/3+1));
}

long TCut(long h, long w, long cutAt)
{
  auto top=cutAt*w;
  if(w%2==0)
  {
    return abs(top-(w/2)*(h-cutAt));
  }else{
    return max(abs(top-(w/2)*(h-cutAt)), abs(top-(w/2+1)*(h-cutAt)));
  }
}