#include <bits/stdc++.h>
#define range(i, l, r) for(long long (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    lint H, W;
    cin >> H >> W;
    if (H % 3 == 0 || W % 3 == 0) {
        cout << 0 << "\n";
        return 0;
    }
    lint min_diff = 1LL << 62;
    // all vertical
    range(w0, 1, W - 1) {
        lint rest_width = W - w0;
        lint w1 = rest_width / 2, w2 = rest_width - w1;
        lint max_width = max(w0, w2), min_width = min(w1, w0);
        min_diff = min(min_diff, (max_width - min_width) * H);
    }
    // all horizontal
    range(h0, 1, H - 1) {
        lint h1 = (H - h0) / 2, h2 = (H - h0) - h1;
        lint max_h = max(h0, h2), min_h = min(h0, h1);
        min_diff = min(min_diff, (max_h - min_h) * W);
    }
    // horizontal -> vertical
    range(h0, 1, H) {
        lint h1 = H - h0;
        lint a0 = h0 * W, a1 = h1 * (W / 2), a2 = h1 * (W - W / 2);
        lint max_a = max(a0, a2), min_a = min(a0, a1);
        min_diff = min(min_diff, max_a - min_a);
    }
    // vertical -> horizontal
    range(w0, 1, W) {
        lint w1 = W - w0;
        lint a0 = H * w0, a1 = (H / 2) * w1, a2 = (H - H / 2) * w1;
        lint max_a = max(a0, a2), min_a = min(a0, a1);
        min_diff = min(min_diff, max_a - min_a);
    }
    cout << min_diff << "\n";
}

Measured memory_bytes: 256