#include <bits/stdc++.h>
using namespace std;
const int maxn = 500010, inf = 1e9;
int n, m;
template <typename T>
inline void read(T &k) {
  int f = 1;
  k = 0;
  char c = getchar();
  while (c < '0' || c > '9') c == '-' && (f = -1), c = getchar();
  while (c <= '9' && c >= '0') k = k * 10 + c - '0', c = getchar();
  k *= f;
}
int main() {
  read(n);
  read(m);
  if (n > m) swap(n, m);
  if (n == 1) return printf("%d\n", m / 6 * 6 + 2 * max(m % 6 - 3, 0)), 0;
  if (n == 2 && m == 2) return puts("0"), 0;
  if (n == 2 && m == 3) return puts("4"), 0;
  if (n == 2 && m == 7) return puts("12"), 0;
  if (n % 2 && m % 2) return printf("%lld\n", 1ll * n * m - 1), 0;
  return printf("%lld\n", 1ll * n * m), 0;
}
