#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using LD = long double;
int main() {
  LL n, m;
  cin >> n >> m;
  map<pair<LL, LL>, LL> mp;
  if (n > m) {
    swap(n, m);
  }
  mp[{1, 1}] = mp[{1, 2}] = mp[{1, 3}] = mp[{2, 2}] = 0;
  mp[{1, 4}] = 2;
  mp[{1, 5}] = 4;
  mp[{1, 6}] = 6;
  mp[{2, 3}] = 4;
  mp[{2, 7}] = 12;
  LL ans;
  if (mp.find({n, m}) != mp.end()) {
    ans = mp[{n, m}];
  } else {
    if (n == 1) {
      LL rem = m % 6;
      ans = m - rem;
      if (rem == 4) {
        ans += 2;
      } else if (rem == 5) {
        ans += 4;
      }
    } else {
      if ((n & 1) & (m & 1)) {
        ans = n * m - 1;
      } else {
        ans = n * m;
      }
    }
  }
  cout << ans << "\n";
}
