#include <bits/stdc++.h>
using namespace std;
int head[1205], lst[1205 * 1205 * 2], nxt[1205 * 1205],
    dir[12][2] = {-3, 0, -2, 1,  -1, 2,  0, 3,  1,  2,  2,  1,
                  3,  0, 2,  -1, 1,  -2, 0, -3, -1, -2, -2, -1};
int tot, n, m;
void ins(int x, int y) {
  lst[++tot] = y;
  nxt[tot] = head[x];
  head[x] = tot;
}
int ma[1205], st[1205], pr[1205], fa[1205], q[1205], v[1205];
int ans, TI, u, t;
int lca(int x, int y) {
  for (TI++;; swap(x, y))
    if (x) {
      if (v[x] == TI) return x;
      v[x] = TI;
      x = fa[pr[ma[x]]];
    }
}
void up(int x, int y, int f) {
  while (fa[x] != f) {
    pr[x] = y;
    if (st[ma[x]] > 0) st[q[++t] = ma[x]] = 0;
    if (fa[x] == x) fa[x] = f;
    if (fa[ma[x]] == ma[x]) fa[ma[x]] = f;
    x = pr[y = ma[x]];
  }
}
int match(int x) {
  for (int i = 1; i <= n; i++) fa[i] = i, st[i] = -1;
  st[q[t = 1] = x] = 0;
  for (int l = 1; l <= t; l++)
    for (int i = head[q[l]]; i; i = nxt[i])
      if (st[lst[i]] < 0) {
        st[lst[i]] = 1;
        pr[lst[i]] = q[l];
        if (!ma[lst[i]]) {
          for (int j = q[l], k = lst[i]; j; j = pr[k = u]) {
            u = ma[j];
            ma[j] = k;
            ma[k] = j;
          }
          return 1;
        }
        st[q[++t] = ma[lst[i]]] = 0;
      } else if (fa[lst[i]] != fa[q[l]] && !st[lst[i]]) {
        int f = lca(lst[i], q[l]);
        up(q[l], lst[i], f);
        up(lst[i], q[l], f);
        for (int j = 1; j <= n; j++) fa[j] = fa[fa[j]];
      }
  return 0;
}
bool chk(int x, int y) {
  if (x < 1 || x > n) return 0;
  if (y < 1 || y > m) return 0;
  return 1;
}
int cal(int x, int y) { return (x - 1) * m + y; }
int main() {
  while (scanf("%d %d", &n, &m) != EOF) {
    TI = tot = 0;
    memset(head, 0, sizeof(head));
    memset(ma, 0, sizeof(ma));
    memset(v, 0, sizeof(v));
    ans = 0;
    if (n <= 11 && m <= 11) {
      for (int i = 1; i <= n; i++) {
        for (int i0 = 1; i0 <= m; i0++) {
          for (int i1 = 0; i1 < 12; i1++) {
            if (chk(i + dir[i1][0], i0 + dir[i1][1])) {
              ins(cal(i, i0), cal(i + dir[i1][0], i0 + dir[i1][1]));
              ins(cal(i + dir[i1][0], i0 + dir[i1][1]), cal(i, i0));
            }
          }
        }
      }
      n = n * m;
      for (int i = 1; i <= n; i++) ans += !ma[i] && match(i);
      printf("%d\n", ans * 2);
    } else {
      if (n > m) swap(n, m);
      if (n == 1) {
        if (m % 6 <= 3) {
          printf("%lld\n", (long long)m / 6 * 6);
        } else if (m % 6 == 4) {
          printf("%lld\n", (long long)m / 6 * 6 + 2);
        } else if (m % 6 == 5) {
          printf("%lld\n", (long long)m / 6 * 6 + 4);
        }
      } else {
        long long sum = (long long)n * m;
        if (sum & 1) sum--;
        printf("%lld\n", sum);
      }
    }
  }
  return 0;
}
