import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  long h, w;
  readf("%s %s\n", &h, &w);

  auto s = h * w;

  long df = s;

  foreach (_; 0..2) {
    swap(h, w);

    foreach (i; 1..w) {
      auto s1 = h * i;

      //v
      auto vl = (w - i) / 2;
      auto s2 = h * vl;
      auto s3 = s - s1 - s2;
      df = min(df, max(max(s1, s2), s3) - min(min(s1, s2), s3));
      //h
      auto hl = h / 2;
      s2 = hl * (w - i);
      s3 = s - s1 - s2;
      df = min(df, max(max(s1, s2), s3) - min(min(s1, s2), s3));
    }
  }

  df.writeln;
}
