#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e3 + 7;
const int MOD = (int)1e9 + 7;
const int LIM = 15000010;
int match[N];
bool used[N];
vector<int> g[N];
bool dfs(int v) {
  if (used[v]) return false;
  used[v] = 1;
  for (auto to : g[v]) {
    if (match[to] == -1 || dfs(match[to])) {
      match[to] = v;
      return true;
    }
  }
  return false;
}
int solvefor(int n, int m) {
  for (int i = 0; i < N; i++) g[i].clear();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if ((i + j) % 2 == 0) {
        int x = i * m + j;
        for (int ii = i - 3; ii <= i + 3; ii++) {
          for (int jj = j - 3; jj <= j + 3; jj++) {
            if (ii >= 0 && jj >= 0 && ii < n && jj < m &&
                abs(i - ii) + abs(j - jj) == 3) {
              int y = ii * m + jj;
              g[x].push_back(y);
            }
          }
        }
      }
    }
  }
  memset(match, -1, sizeof match);
  for (int i = 0; i <= n * m; i++) {
    memset(used, 0, sizeof used);
    dfs(i);
  }
  int ans = 0;
  for (int i = 0; i <= n * m; i++) {
    if (match[i] != -1) ++ans;
  }
  return 2 * ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  if (m < n) swap(n, m);
  if (n == 1) {
    int res[] = {0, 1, 2, 3, 2, 1};
    cout << n * 1ll * m - res[m % 6];
    return 0;
  }
  if (m <= 10) {
    cout << solvefor(n, m);
    return 0;
  }
  if (n % 2 == 0 or m % 2 == 0)
    cout << n * 1ll * m;
  else
    cout << n * 1ll * m - 1;
  return 0;
}
