#include <bits/stdc++.h>
const int dr[] = {3, 2, 1, 0, -3, -2, -1, 0, 2, 1, 0, -3, -2, -1};
const int dc[] = {0, 1, 2, 3, 0, 1, 2, 3, -1, -2, -3, 0, -1, -2};
long long n, m;
int cnt, g[2000][2000];
std::map<std::pair<int, int>, int> MAP;
inline int FIND(std::pair<int, int> p) {
  if (MAP.count(p)) return MAP[p];
  return MAP[p] = ++cnt;
}
int sx, sy;
inline void build() {
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      for (int k = 0; k < 14; ++k) {
        int ni = i + dr[k], nj = j + dc[k];
        if (ni < 0 || ni >= n || nj < 0 || nj >= m) continue;
        g[FIND(std::pair<int, int>(i, j))][FIND(std::pair<int, int>(ni, nj))] =
            1;
        sy++;
      }
    }
}
int zx[2000], zy[2000];
int dx[2000], dy[2000], dis;
bool vis[2000];
inline bool bfs() {
  std::queue<int> Q;
  dis = 0x3f3f3f3f;
  memset(dx, -1, sizeof dx);
  memset(dy, -1, sizeof dy);
  for (int i = 1; i <= sx; i++)
    if (zx[i] == -1) Q.push(i), dx[i] = 0;
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    if (dx[u] > dis) break;
    for (int v = 1; v <= sy; v++)
      if (g[u][v] && dy[v] == -1) {
        dy[v] = dx[u] + 1;
        if (zy[v] == -1)
          dis = dy[v];
        else {
          dx[zy[v]] = dy[v] + 1;
          Q.push(zy[v]);
        }
      }
  }
  return dis != 0x3f3f3f3f;
}
inline bool dfs(int u) {
  for (int v = 1; v <= sy; v++)
    if (!vis[v] && g[u][v] && dy[v] == dx[u] + 1) {
      vis[v] = 1;
      if (zy[v] != -1 && dy[v] == dis) continue;
      if (zy[v] == -1 || dfs(zy[v])) {
        zy[v] = u;
        zx[u] = v;
        return 1;
      }
    }
  return 0;
}
inline int work() {
  int res = 0;
  memset(zx, -1, sizeof zx);
  memset(zy, -1, sizeof zy);
  while (bfs()) {
    memset(vis, 0, sizeof vis);
    for (int i = 1; i <= sx; i++)
      if (zx[i] == -1 && dfs(i)) res++;
  }
  return res;
}
int main() {
  scanf("%lld%lld", &n, &m);
  if (n > m) std::swap(n, m);
  if (n == 1)
    printf("%lld", 6 * (m / 6) + 2 * std::max(m % 6 - 3, 1ll * 0));
  else if (n <= 20 && m <= 20) {
    sx = n * m;
    sy = 0;
    build();
    printf("%d", work());
  } else {
    if (n % 2 == 0 && m % 2 == 0)
      printf("%lld", n * m);
    else if (n % 2 == 0 && m % 2 || n % 2 && m % 2 == 0)
      printf("%lld", n * m);
    else
      printf("%lld", n * m - 1);
  }
  return 0;
}
