import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

long[2] dfs(int depth, long h, long w)
{
  if (depth == 2) {
    return [h * w, h * w];
  }
  long[2] ans = [long.min / 4, long.max / 4];
  // split row
  for (int i = -1; i <= 1; ++i) {
    long mh = h / 2 + i;
    if (mh <= 0) {
      continue;
    }
    long rh = h - mh;
    if (rh <= 0) {
      continue;
    }
    auto res = dfs(depth + 1, rh, w);
    long low = min(mh * w, res[0]);
    long high = max(mh * w, res[1]);
    if (ans.back - ans.front > high - low) {
      ans[0] = low;
      ans[1] = high;
    }
  }
  for (int i = -1; i <= 1; ++i) {
    long mh = h / 3 + i;
    if (mh <= 0) {
      continue;
    }
    long rh = h - mh;
    if (rh <= 0) {
      continue;
    }
    auto res = dfs(depth + 1, rh, w);
    long low = min(mh * w, res[0]);
    long high = max(mh * w, res[1]);
    if (ans.back - ans.front > high - low) {
      ans[0] = low;
      ans[1] = high;
    }
  }
  // split col
  for (int i = -1; i <= 1; ++i) {
    long mw = w / 2 + i;
    if (mw <= 0) {
      continue;
    }
    long rw = w - mw;
    if (rw <= 0) {
      continue;
    }
    auto res = dfs(depth + 1, h, rw);
    long low = min(h * mw, res[0]);
    long high = max(h * mw, res[1]);
    if (ans.back - ans.front > high - low) {
      ans[0] = low;
      ans[1] = high;
    }
  }
  for (int i = -1; i <= 1; ++i) {
    long mw = w / 3 + i;
    if (mw <= 0) {
      continue;
    }
    long rw = w - mw;
    if (rw <= 0) {
      continue;
    }
    auto res = dfs(depth + 1, h, rw);
    long low = min(h * mw, res[0]);
    long high = max(h * mw, res[1]);
    if (ans.back - ans.front > high - low) {
      ans[0] = low;
      ans[1] = high;
    }
  }
  return ans;
}

void main() {
  auto hw = readln.chomp.split.map!(to!int);
  auto res = dfs(0, hw.front, hw.back);
  stderr.writeln = res;
  writeln = res.back - res.front;
}
