#include <bits/stdc++.h>
using namespace std;
struct BipartiteMatcher {
  vector<vector<int>> g;
  vector<int> L, R;
  vector<bool> vis;
  BipartiteMatcher(int n, int m) : g(n), L(n, -1), R(m, -1), vis(n) {}
  void addEdge(int a, int b) { g[a].emplace_back(b); }
  bool match(int x) {
    if (vis[x]) return 0;
    vis[x] = 1;
    for (int v : g[x])
      if (R[v] == -1) return R[L[x] = v] = x, 1;
    for (int v : g[x])
      if (match(R[v])) return R[L[x] = v] = x, 1;
    return 0;
  }
  int solve() {
    int cnt = 1;
    while (cnt--) {
      fill(vis.begin(), vis.end(), 0);
      for (int i = 0; i < L.size(); ++i) {
        cnt |= L[i] == -1 and match(i);
      }
    }
    int res = 0;
    for (int i = 0; i < L.size(); ++i) res += L[i] != -1;
    return res;
  }
};
int solve(int n, int m) {
  BipartiteMatcher BM(n * m, n * m);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      if ((i + j) % 2 == 1) continue;
      for (int k = max(i - 3, 0); k <= min(i + 3, n - 1); ++k) {
        for (int l = max(j - 3, 0); l <= min(j + 3, m - 1); ++l) {
          if ((k + l) % 2 == 0) continue;
          if (abs(i - k) + abs(j - l) == 3) {
            BM.addEdge(i * m + j, k * m + l);
          }
        }
      }
    }
  return 2 * BM.solve();
}
int main() {
  int n, m;
  cin >> n >> m;
  if (n > m) swap(n, m);
  if (n <= 20 and m <= 20)
    cout << solve(n, m) << endl;
  else if (n == 1)
    cout << 2 * (m / 6 * 3 + max(m % 6 - 3, 0)) << endl;
  else
    cout << (n * 1ll * m) / 2 * 2 << endl;
  ;
  return 0;
}
