#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-15;
const int INF = 1e9 + 7;
const long long LINF = 8e18 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  if (n > m) {
    swap(n, m);
  }
  if (n == 1) {
    if (m <= 3) {
      cout << 0 << endl;
      return 0;
    }
    if ((m + 2) % 6 == 0) {
      cout << m - 2 << endl;
      return 0;
    }
    if ((m + 1) % 6 == 0) {
      cout << m - 1 << endl;
      return 0;
    }
    cout << m / 6 * 6 << endl;
    return 0;
  }
  if (n == 2) {
    if (m <= 2) {
      cout << 0 << endl;
      return 0;
    }
    if (m == 3) {
      cout << 4 << endl;
      return 0;
    }
    if (m == 7) {
      cout << 12 << endl;
      return 0;
    }
    cout << 2 * m << endl;
    return 0;
  }
  if (n % 2 == 0 || m % 2 == 0) {
    cout << n * m << endl;
    return 0;
  }
  cout << n * m - 1 << endl;
}
