#include <bits/stdc++.h>
using namespace std;
template <class TH>
void _dbg(const char* sdbg, TH h) {
  cerr << sdbg << " = " << h << endl;
}
template <class TH, class... TA>
void _dbg(const char* sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << " = " << h << ", ";
  _dbg(sdbg + 1, a...);
}
const int maxn = (1e6) + 7;
const int maxk = 20;
const int inf = (1e9) + 7;
const long long LLinf = ((long long)1e18) + 7LL;
const long double eps = 1e-9;
const long long mod = 1e9 + 7;
struct Matching {
  int n, wynik;
  vector<int> odl, str, para, odw;
  const vector<vector<int> >& V;
  Matching(int N, const vector<vector<int> >& M, const vector<int>& s)
      : n(N), odl(n + 1), str(s), para(n + 1), odw(n + 1), V(M) {}
  bool DFS(int v, int ojciec, int zostalo) {
    if (zostalo < 0) return false;
    odw[v] = 1;
    if (!str[v]) {
      if (!para[v]) return (para[v] = ojciec);
      if (DFS(para[v], v, zostalo - 1)) return (para[v] = ojciec);
      return false;
    }
    for (int i = 0; i < ((int)(V[v]).size()); i++)
      if (odl[V[v][i]] == odl[v] + 1 && !odw[V[v][i]] &&
          DFS(V[v][i], v, zostalo - 1))
        return (para[v] = V[v][i]);
    return false;
  }
  int sciezki() {
    memset(&odl[0], 0, 4 * (n + 1));
    memset(&odw[0], 0, 4 * (n + 1));
    int minodl = 2 * n + 5, ilezmian = 0;
    queue<pair<int, int> > Q;
    for (int i = 1; i <= n; i++)
      if (str[i] && !para[i]) {
        Q.push(make_pair(i, 1));
        odl[i] = 1;
      }
    while (!Q.empty()) {
      int akt = Q.front().first, od = Q.front().second;
      Q.pop();
      if (!str[akt]) {
        if (para[akt]) {
          Q.push(make_pair(para[akt], od + 1));
          odl[para[akt]] = od + 1;
        } else
          minodl = min(minodl, od);
        continue;
      }
      for (int i = 0; i < ((int)(V[akt]).size()); i++)
        if (odl[V[akt][i]] == 0) {
          Q.push(make_pair(V[akt][i], od + 1));
          odl[V[akt][i]] = od + 1;
        }
    }
    for (int i = 1; i <= n; i++)
      if (!odw[i] && str[i] && !para[i]) ilezmian += DFS(i, -1, minodl - 1);
    return ilezmian;
  }
  int matching() {
    int ile = 0, akt;
    while ((akt = sciezki())) ile += akt;
    return wynik = ile;
  }
  vector<int> mpn() {
    vector<int> stan(n + 1, 0);
    queue<int> Q;
    for (int i = 1; i <= n; i++) {
      if (!para[i]) {
        stan[i] = 1;
        Q.push(i);
      }
    }
    while (!Q.empty()) {
      int x = Q.front();
      Q.pop();
      for (auto el : V[x]) {
        if (stan[el] == 0) {
          stan[el] = -1;
          stan[para[el]] = 1;
          Q.push(para[el]);
        }
      }
    }
    vector<int> odp;
    for (int i = 1; i <= n; i++)
      if (stan[i] == 1 || (!stan[i] && str[i])) odp.push_back(i);
    return odp;
  }
};
vector<pair<int, int> > mov = {{-1, -2}, {-1, 2}, {-2, -1}, {-2, 1},
                               {1, -2},  {1, 2},  {2, -1},  {2, 1},
                               {3, 0},   {0, 3},  {-3, 0},  {0, -3}};
int A, B;
int numer(int a, int b) { return (a - 1) * B + b; }
long long wyn(int a, int b) {
  A = a;
  B = b;
  vector<vector<int> > V;
  vector<int> cnt;
  V.resize(numer(a, b) + 10);
  cnt.resize(numer(a, b) + 10);
  for (int i = 1; i <= a; i++)
    for (int j = 1; j <= b; j++) {
      for (auto s : mov) {
        int ii = i + s.first;
        int jj = j + s.second;
        if (1 <= ii && ii <= a && 1 <= jj && jj <= b) {
          V[numer(i, j)].push_back(numer(ii, jj));
        }
      }
      cnt[numer(i, j)] = (i + j) & 1;
    }
  Matching xd(numer(a, b) + 5, V, cnt);
  return xd.matching() * 2LL;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long x, y;
  cin >> x >> y;
  long long res = 0LL;
  if (x > y) swap(x, y);
  if (x == 1LL) {
    long long cnt = y / 6;
    y -= cnt * 6;
    cout << cnt * 6 + max(0LL, y - 3) * 2LL;
    return 0;
  }
  while (x * y > 1000) {
    if (x > 20) {
      if (x > 20050) {
        res += 20000LL * y;
        x -= 20000LL;
      } else {
        res += y * 4LL;
        x -= 4LL;
      }
    } else {
      if (y > 20) {
        if (y > 20050) {
          res += x * 20000LL;
          y -= 20000LL;
        } else {
          res += 4LL * x;
          y -= 4LL;
        }
      }
    }
  }
  cout << res + wyn(x, y);
  return 0;
}
