#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
long long read_long() {
  long long ans = 0;
  char c;
  bool started = false;
  bool is_negative = false;
  while (true) {
    c = getchar();
    if ((c < '0' || c > '9') && c != '-' && !started) continue;
    if ((c < '0' || c > '9') && c != '-' && started) break;
    if (started) {
      ans = ans * 10;
    }
    started = true;
    if (c == '-')
      is_negative = true;
    else
      ans += c - '0';
  }
  if (is_negative) ans *= -1;
  return ans;
}
int n, m;
int sz;
map<pair<int, int>, int> id;
vector<int> g[11111];
int dx[12] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1};
int dy[12] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2};
vector<int> used, mt;
bool dfs(int v) {
  if (used[v]) return false;
  used[v] = 1;
  for (__typeof(g[v].begin()) it = g[v].begin(); it != g[v].end(); it++) {
    int to = *it;
    if (mt[to] == -1 || dfs(mt[to])) {
      mt[to] = v;
      return true;
    }
  }
  return false;
}
int solve() {
  id.clear();
  sz = n * m;
  for (int i = 0; i < sz; i++) {
    g[i].clear();
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      id[make_pair(i, j)] = i * m + j;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int d = 0; d < 12; d++) {
        int x = i + dx[d];
        int y = j + dy[d];
        if (x >= 0 && y >= 0 && x < n && y < m) {
          g[id[make_pair(i, j)]].push_back(id[make_pair(x, y)]);
        }
      }
    }
  }
  mt.assign(sz, -1);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if ((i + j) & 1) continue;
      used.assign(sz, 0);
      ans += dfs(id[make_pair(i, j)]);
    }
  }
  return ans * 2;
}
long long calc(int n, int m) {
  if (n >= 3 && m >= 3) {
    long long ans = n * 1ll * m;
    if (ans & 1) ans--;
    return ans;
  }
  if (n > m) swap(n, m);
  if (n == 1) {
    long long ans = m / 6 * 1ll * 6;
    m %= 6;
    if (m <= 3)
      ans += 0;
    else if (m == 4)
      ans += 2;
    else if (m == 5)
      ans += 4;
    return ans;
  }
  if (m == 2) return 0;
  if (m >= 10 || m % 4 < 3) return n * 1ll * m;
  return n * 1ll * m - 2;
}
int main() {
  cin >> n >> m;
  cout << calc(n, m) << endl;
  return 0;
  return 0;
}
