#include <bits/stdc++.h>
using namespace std;
int read() {
  int v = 0, f = 1;
  char c = getchar();
  while (c < 48 || 57 < c) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
  return v * f;
}
const int INF = 1e9;
const int N = 1000000, M = 1000000;
int n, m;
struct EG {
  int a, b, c;
} eg[M];
int head[N], en, S, T;
int dis[N];
bool vis[N];
void SetEdge(int u, int v, int w) {
  eg[++en] = (EG){v, head[u], w};
  head[u] = en;
  eg[++en] = (EG){u, head[v], 0};
  head[v] = en;
}
void Clear() {
  memset(head, 0, sizeof head);
  en = 1;
}
bool bfs() {
  memset(vis, 0, sizeof vis);
  vis[S] = 1;
  queue<int> Q;
  Q.push(S);
  dis[S] = 0;
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int e = head[u]; e; e = eg[e].b) {
      int v = eg[e].a;
      if (!vis[v] && eg[e].c > 0) {
        vis[v] = 1;
        dis[v] = dis[u] + 1;
        Q.push(v);
      }
    }
  }
  return vis[T];
}
int dfs(int u, int rem) {
  if (u == T || rem == 0) return rem;
  int flow = 0, f;
  for (int e = head[u]; e; e = eg[e].b) {
    int v = eg[e].a;
    if (dis[u] + 1 == dis[v] && (f = dfs(v, min(rem, eg[e].c))) > 0) {
      eg[e].c -= f;
      eg[e ^ 1].c += f;
      flow += f;
      rem -= f;
      if (rem == 0) break;
    }
  }
  if (!flow) dis[u] = -1;
  return flow;
}
int dinic() {
  int re = 0;
  while (bfs()) re += dfs(S, INF);
  return re;
}
int get(int i, int j) { return (i - 1) * m + j; }
int main() {
  Clear();
  n = read(), m = read();
  int _m;
  if (n > m) swap(n, m);
  if (n == 1) {
    _m = m / 6 * 6;
    m %= 6;
    if (m == 0) {
      m = 6;
      _m -= 6;
    }
  }
  if (n <= 20 && m <= 20) {
    S = n * m + 1, T = S + 1;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++)
        if ((i + j) & 1)
          SetEdge(S, get(i, j), 1);
        else
          SetEdge(get(i, j), T, 1);
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++)
        if ((i + j) & 1)
          for (int k = 1; k <= n; k++)
            for (int l = 1; l <= m; l++)
              if (!((k + l) & 1))
                if (abs(i - k) + abs(j - l) == 3)
                  SetEdge(get(i, j), get(k, l), 1);
    if (n > 1)
      printf("%d\n", dinic() * 2);
    else
      printf("%d\n", dinic() * 2 + _m);
  } else {
    if ((n & 1) && (m & 1))
      printf("%lld\n", 1LL * n * m - 1);
    else
      printf("%lld\n", 1LL * n * m);
  }
}
