#include <bits/stdc++.h>
using namespace std;
class matching {
 public:
  vector<vector<int> > g;
  vector<int> pa, pb, was;
  int n, m, res, iter;
  matching(int _n, int _m) : n(_n), m(_m) {
    assert(0 <= n && 0 <= m);
    pa = vector<int>(n, -1);
    pb = vector<int>(m, -1);
    was = vector<int>(n, 0);
    g.resize(n);
    res = 0, iter = 0;
  }
  void add_edge(int from, int to) {
    assert(0 <= from && from < n && 0 <= to && to < m);
    g[from].push_back(to);
  }
  bool dfs(int v) {
    was[v] = iter;
    for (int u : g[v])
      if (pb[u] == -1) return pa[v] = u, pb[u] = v, true;
    for (int u : g[v])
      if (was[pb[u]] != iter && dfs(pb[u])) return pa[v] = u, pb[u] = v, true;
    return false;
  }
  int solve() {
    while (true) {
      iter++;
      int add = 0;
      for (int i = 0; i < n; i++)
        if (pa[i] == -1 && dfs(i)) add++;
      if (add == 0) break;
      res += add;
    }
    return res;
  }
};
int solve(int n, int m) {
  matching ma(n * m, n * m);
  for (int i = 0; i < n; i++) {
    for (int ii = 0; ii < m; ii++) {
      for (int j = 0; j < n; j++) {
        for (int jj = 0; jj < m; jj++) {
          if ((abs(i - j) + abs(ii - jj)) == 3) {
            if ((i + ii) & 1)
              ma.add_edge(i * m + ii, j * m + jj);
            else
              ma.add_edge(j * m + jj, i * m + ii);
          }
        }
      }
    }
  }
  return ma.solve();
}
int main() {
  long long n, m;
  cin >> n >> m;
  if (n > m) swap(n, m);
  if (m < 10)
    cout << solve(n, m) * 2 << "\n";
  else if (n == 1) {
    int res = 0;
    if (m % 6 == 1 || m % 6 == 5) res = 1;
    if (m % 6 == 2 || m % 6 == 4) res = 2;
    if (m % 6 == 3) res = 3;
    cout << (n * m - res) << "\n";
  } else
    cout << (n * m) / 2 * 2 << "\n";
  return 0;
}
