#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
const int MAXN = 100010;
const int INF = 2147483600;
long long n, m;
void RET(long long x) {
  cout << x << endl;
  exit(0);
}
inline void work() {
  if (n == 3) {
    if (m == 2)
      RET(4);
    else
      cout << n * m << endl;
    exit(0);
  }
  if (n == 7) {
    if (m == 2)
      RET(12);
    else
      cout << n * m << endl;
    exit(0);
  }
  cout << n * m << endl;
  exit(0);
}
int main() {
  n = read(), m = read();
  if (n > m) swap(n, m);
  if (n == 1) RET((m - (m % 6)) + max(0ll, (m % 6 - 3) * 2));
  if (n % 2 == 0 && m % 2 == 0) {
    if (m == 2 && n == 2)
      RET(0);
    else
      cout << n * m << endl;
    return 0;
  }
  if ((n + m) & 1) {
    if (m & 1) swap(n, m);
    work();
  }
  cout << n * m - 1;
  return 0;
}
