#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast", "inline")
#pragma GCC target("avx,avx2")
using namespace std;
template <class t>
inline t read(t &x) {
  char c = getchar();
  bool f = 0;
  x = 0;
  while (!isdigit(c)) f |= c == '-', c = getchar();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  if (f) x = -x;
  return x;
}
template <class t, class... A>
inline void read(t &x, A &...a) {
  read(x);
  read(a...);
}
template <class t>
inline void write(t x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x > 9) write(x / 10);
    putchar('0' + x % 10);
  }
}
long long n, m;
signed main() {
  read(n, m);
  if (n > m) swap(n, m);
  if (n == 1) {
    if (m % 6 == 0)
      write(m);
    else if (m % 6 <= 3)
      write(m - m % 6);
    else
      write(m - (6 - m % 6));
    return 0;
  }
  if (n == 2 && m == 2)
    write(0);
  else if (n == 2 && m == 3)
    write(4);
  else if (n == 2 && m == 7)
    write(12);
  else if ((n & 1) && (m & 1))
    write(n * m - 1);
  else
    write(n * m);
}
