import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

long ans = 1L<<60;

void main(){
    long h, w;
    readVars(h, w);
    calc(h, w);
    calc(w, h);
    writeln(ans);
}

void calc(long h, long w){
    long s0, s1, s2;
    foreach (a ; 1 .. w) {
        s0 = a * h;

        s1 = h * ((w - a + 1) / 2);
        s2 = h * ((w - a) / 2);

        ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2));

        s1 = (w - a) * ((h + 1) / 2);
        s2 = (w - a) * (h / 2);

        ans = min(ans, max(s0, s1, s2) - min(s0, s1, s2));
    }
}

void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}