#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long ans;
long long a[] = {0, 0,  0,  0, 2, 4,  0,  0,  4, 8,  10, 0,  4,
                 8, 12, 14, 2, 8, 12, 16, 20, 4, 10, 14, 20, 24};
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cerr << "HELLO WORLD\n";
  cin >> n >> m;
  if (n < 4 || m < 4) {
    if (n < 4 && m < 4) return cout << a[(n - 1) * 5 + m] << '\n', false;
    if (m < 4) swap(n, m);
    if (n == 1)
      return cout << m - (m % 6) + (max(0ll, (m % 6) - 3ll)) * 2ll << '\n',
             false;
    if (n % 2 == 0) {
      if (m % 4 < 3 || !(n % 4) || m > 7)
        return cout << (n * m) - ((n & 1) & (m & 1)) << '\n', false;
      return cout << (n * m) - 2 << '\n', false;
    }
    return cout << (n * m) - ((n & 1) & (m & 1)) << '\n', false;
  } else
    ans = (long long)n * (long long)m;
  return cout << ans - ((n & 1) & (m & 1)) << '\n', false;
}
