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;

            // h を分割
            long h1 = h / 2;
            long h2 = h - h1;
            long b = h1 * (w - i);
            long c = h2 * (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;

            // w を分割
            long w1 = (w - i) / 2;
            long w2 = (w - i) - w1;
            long b = h * w1
            long c = h * w2;
            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));
}
