#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
vector<int> G[maxn];
bool v[maxn];
int match[maxn], n, m;
int cal(int x, int y) { return (x - 1) * m + y; }
void add(int x, int y) { G[x].push_back(y); }
bool dfs(int x) {
  for (int i = 0; i < G[x].size(); i++) {
    int y = G[x][i];
    if (!v[y]) {
      v[y] = 1;
      if (!match[y] || dfs(match[y])) {
        match[y] = x;
        return 1;
      }
    }
  }
  return 0;
}
int main() {
  scanf("%d%d", &n, &m);
  if (n == 1 || m == 1) {
    long long ans = (long long)n * m / 6 * 6;
    long long tmp = (long long)n * m - ans;
    if (tmp > 3) {
      ans += (tmp - 3) * 2;
    }
    printf("%lld\n", ans);
    return 0;
  }
  if ((n == 2 && m == 7) || (n == 7 && m == 2)) {
    printf("12\n");
    return 0;
  }
  if (n <= 3 && m <= 3) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        for (int k = 1; k <= n; k++) {
          for (int t = 1; t <= m; t++) {
            if (abs(i - k) + abs(j - t) == 3) {
              add(cal(i, j), cal(k, t));
            }
          }
        }
      }
    }
    int ans = 0;
    for (int i = 1; i <= n * m; i++) {
      memset(v, 0, sizeof(v));
      if (dfs(i)) ans++;
    }
    printf("%d\n", ans);
  } else {
    long long ans = ((long long)n * m);
    if (ans % 2 == 1) ans--;
    printf("%lld\n", ans);
  }
}
