#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する
ll h, w;

ll func1() {
//    ll min_v = min(h * (w % 3), w * (h % 3));
    ll min_v = min(h, w);
    if (min(h % 3, w % 3) == 0)min_v = 0;
    REP(i, 0, w + 1) {
        ll s1 = h / 2 * i;
//        int s2 = h / 2 * (w - i);
        ll s3 = (h - h / 2) * i;
        ll s4 = h * (w - i);

//        min_v = min(min_v, max({labs(s1 - s3), labs(s3 - s4), labs(s4 - s1)}));
        min_v = min(min_v, max({s1, s3, s4}) - min({s1, s3, s4}));
    }
    REP(i, 0, h + 1) {
        ll s1 = w / 2 * i;
//            int s2 = w / 2 * (h - i);
        ll s3 = (w - w / 2) * i;
        ll s4 = w * (h - i);
//        min_v = min(min_v, max({labs(s1 - s3), labs(s3 - s4), labs(s4 - s1)}));
        min_v = min(min_v, max({s1, s3, s4}) - min({s1, s3, s4}));
    }
    return min_v;

}

ll func2() {
    ll H = h;
    ll W = w;
    int x, y;
    int minv = H * W;
    if (H % 3 == 0 || W % 3 == 0) {
        minv = 0;
    } else {
        int tmp = min(W, H);
        if (minv > tmp) {
            minv = tmp;
            x = 114514;
            y = 8101919;
        }
        for (int i = -1; i <= 1; i++) {
            int k = H / 3 + i;
            int s1 = k * W;
            int s2 = (H - k) * (W / 2);
            int s3 = (H - k) * (W - (W / 2));
            int maxs = max(s1, max(s2, s3));
            int mins = min(s1, min(s2, s3));
            tmp = maxs - mins;
            if (minv > tmp) {
                minv = tmp;
                x = k;
                y = W / 2;
            }
        }
        swap(H, W);
        for (int i = -1; i <= 1; i++) {
            int k = H / 3 + i;
            int s1 = k * W;
            int s2 = (H - k) * (W / 2);
            int s3 = (H - k) * (W - (W / 2));
            int maxs = max(s1, max(s2, s3));
            int mins = min(s1, min(s2, s3));
            tmp = maxs - mins;
            if (minv > tmp) {
                minv = tmp;
                x = k;
                y = W / 2;
            }
        }
    }
//    cout << minv << endl;
    return minv;
}

ll labs(ll a) {
    if (a < 0) return -a;
    return a;
}


int main() {
    cin >> h >> w;
    cout << func1() << endl;
//    cout << func2() << endl;

//    REP(i, 1, 1000) {
//        REP(j, 1, 1000) {
//            h = i;
//            w = j;
//            ll a = func1();
//            ll b = func2();
//
//            if (a != b) {
//                cout << "i:" << i << ",j:" << j << endl;
//                cout << "a:" << a << ",b:" << b << endl;
//            }
//        }
//        if(i % 100 == 0)cout << "i = " << i << " ,finished" << endl;
//    }

}


Measured memory_bytes: 256