#include <bits/stdc++.h>
using namespace std;
template <class T>
bool mini(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool maxi(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  long long n, m;
  cin >> n >> m;
  if (n > m) swap(n, m);
  if (n == 1) return cout << (m - m % 6) + max(0ll, m % 6 - 3) * 2, 0;
  if (m * n & 1) return cout << n * m - 1 << "\n", 0;
  if (n == 2) {
    if (m == 2) return cout << 0 << "\n", 0;
    if (m == 3) return cout << 4 << "\n", 0;
    if (m == 7) return cout << 12 << "\n", 0;
    return cout << m * 2 << "\n", 0;
  }
  return cout << n * m << "\n", 0;
}
