#include <bits/stdc++.h>
using namespace std;
const int MAXS = 2e4;
int sizeL = MAXS, sizeR = MAXS;
bool vis[MAXS];
int par[MAXS];
vector<int> adj[MAXS];
bool match(int u) {
  for (int v : adj[u]) {
    if (vis[v]) continue;
    vis[v] = true;
    if (par[v] == -1 || match(par[v])) {
      par[v] = u;
      return true;
    }
  }
  return false;
}
int maxmatch() {
  fill_n(par, sizeR, -1);
  int ret = 0;
  for (int i = 0; i < sizeL; i++) {
    fill_n(vis, sizeR, false);
    ret += match(i);
  }
  return ret;
}
long long try_board(int n, int m) {
  vector<vector<int> > idxl(n, vector<int>(m, 0)), idxr(n, vector<int>(m, 0));
  int nl = 0, nr = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if ((i + j) % 2 == 0) {
        idxl[i][j] = nl++;
      } else {
        idxr[i][j] = nr++;
      }
    }
  }
  sizeL = nl;
  sizeR = nr;
  for (auto i = (0); i != (nl); ++i) adj[i].clear();
  for (int i = 0; i < n; i++) {
    for (int first = 0; first < n; first++) {
      if (abs(i - first) >= 3) continue;
      for (int j = 0; j < m; j++) {
        if ((i + j) % 2 != 0) continue;
        for (int second = 0; second < m; second++) {
          int d = abs(i - first) + abs(j - second);
          if (d != 3) continue;
          assert((first + second) % 2 == 1);
          adj[idxl[i][j]].push_back(idxr[first][second]);
        }
      }
    }
  }
  return 2LL * maxmatch();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int N, M;
  cin >> N >> M;
  if (N > M) swap(N, M);
  int rN = N % 6, rM = M % 6;
  long long ret = 1LL * N * M - 1LL * (rN * rM);
  for (int qN = 0; qN < 10 && 6 * qN + rN <= N; qN++) {
    for (int qM = 0; qM < 10 && 6 * qM + rM <= M; qM++) {
      int sn = 6 * qN + rN;
      int sm = 6 * qM + rM;
      long long alt = 1LL * N * M;
      alt -= 1LL * sn * sm;
      alt += try_board(sn, sm);
      ret = max(ret, alt);
    }
  }
  if (N == 2) {
    int tmp[4] = {0, -2, -4, -2};
    ret = max(ret, 2LL * M + tmp[M % 4]);
  }
  cout << ret << endl;
  return 0;
}
