// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long H, W;
    scan(H, W);
    long ans = long.max;
    foreach (h; 1 .. H)
    {
        long a = h * W;
        long b = (H - h) * (W / 2);
        long c = (H - h) * (W - W / 2);
        if (a == 0 || b == 0 || c == 0)
            continue;
        dprint(a, b, c);
        ans = ans.min(max(a, b, c) - min(a, b, c));
    }
    foreach (h; 1 .. H)
    {
        long a = h * W;
        long b = ((H - h) / 2) * W;
        long c = ((H - h) - (H - h) / 2) * W;
        if (a == 0 || b == 0 || c == 0)
            continue;
        dprint(a, b, c);
        ans = ans.min(max(a, b, c) - min(a, b, c));
    }
    foreach (w; 1 .. W)
    {
        long a = w * H;
        long b = (W - w) * (H / 2);
        long c = (W - w) * (H - H / 2);
        if (a == 0 || b == 0 || c == 0)
            continue;
        dprint(a, b, c);
        ans = ans.min(max(a, b, c) - min(a, b, c));
    }
    foreach (w; 1 .. W)
    {
        long a = w * H;
        long b = ((W - w) / 2) * H;
        long c = ((W - w) - (W - w) / 2) * H;
        if (a == 0 || b == 0 || c == 0)
            continue;
        dprint(a, b, c);
        ans = ans.min(max(a, b, c) - min(a, b, c));
    }
    writeln(ans);
}
