#include <bits/stdc++.h>
using namespace std;

long solve(long x, long y) {
    long ans = LONG_MAX;
    for (long i=1; i<x; i++) {
        long d1 = floor(y / 2), d2 = floor((x-i)/2);
        long sa = y * i,
             sb1 = d1 * (x - i), sc1 = (y - d1) * (x - i),
             sb2 = d2 * y, sc2 = (x - i - d2) * y;
        long ans1 = abs(max({sa, sb1, sc1}) - min({sa, sb1, sc1})),
             ans2 = abs(max({sa, sb2, sc2}) - min({sa, sb2, sc2}));
        ans = min({ans, ans1, ans2});
    }
    return ans;
}

int main(){
    long h, w;
    cin >> h >> w;
    cout << min(solve(h, w), solve(w, h)) << endl;
}