import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int h, int w) {

    long _calc(long h, long w) {
        long ans = long.max;

        for (int i = 1; i < w; i++) {
            long a = h * i;

            long hTop = h / 2;
            long hBtm = h - hTop;
            long b = hTop * (w - i);
            long c = hBtm * (w - i);
            ans = min(ans, max(a, b, c) - min(a, b, c));
        }

        for (int i = 1; i < w - 1; i++) {
            long a = h * i;

            long w2 = w - i;
            long wLeft = w2 / 2;
            long wRight = w2 - wLeft;
            long b = h * wLeft;
            long c = h * wRight;
            ans = min(ans, max(a, b, c) - min(a, b, c));
        }
        return ans;
    }

    return min(_calc(h, w), _calc(w, h));
}

void main() {
    auto hw = readints;
    int h = hw[0], w = hw[1];
    writeln(calc(h, w));
}
