#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, next;
  edge(int _to = 0, int _next = 0) : to(_to), next(_next) {}
};
struct Bgraph {
  static const int maxn = 1100;
  edge e[maxn * maxn];
  int h[maxn], xb, m[maxn], n;
  bool vi[maxn];
  void addedge(int x, int y) {
    e[++xb] = edge(y, h[x]);
    h[x] = xb;
  }
  bool dfs(int x) {
    if (vi[x]) return 0;
    vi[x] = 1;
    for (int i = h[x]; i; i = e[i].next)
      if (!m[e[i].to] || dfs(m[e[i].to])) {
        m[e[i].to] = x;
        return 1;
      }
    return 0;
  }
  int match() {
    int s = 0;
    for (int i = n; i; --i) {
      for (register int j = 1; j <= n; j++) vi[j] = 0;
      if (dfs(i)) ++s;
    }
    return s;
  }
} g;
const int N = 305;
long long n, m;
int a[N][N], i, j;
namespace T1 {
int xb;
inline void main() {
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j) a[i][j] = ++xb;
  g.n = n * m;
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j)
      if ((i + j) & 1) {
        for (int k = -3; k <= 3; ++k)
          for (int l = -3; l <= 3; ++l)
            if (abs(k) + abs(l) == 3 && i + k > 0 && i + k <= n && j + l > 0 &&
                j + l <= m)
              g.addedge(a[i][j], a[i + k][j + l]);
      }
  cout << g.match() * 2 << '\n';
  exit(0);
}
}  // namespace T1
int main() {
  cin >> n >> m;
  if (n > m) swap(n, m);
  if (n * m <= 300) T1::main();
  if (n == 1) {
    long long ans = m / 6 * 6;
    m %= 6;
    if (m > 3) ans += 2 * (m - 3);
    cout << ans;
    return 0;
  }
  cout << n * m - n * m % 2 << '\n';
  return 0;
}
