#include <bits/stdc++.h>
using namespace std;
long long n, m;
int main() {
  cin >> n >> m;
  if (n > m) {
    swap(n, m);
  }
  if (n % 2 == 0 && m % 2 == 0) {
    if (n == 2 && m == 2)
      cout << 0 << endl;
    else
      cout << n * m << endl;
    return 0;
  }
  if (n + m <= 4) {
    cout << 0 << endl;
    return 0;
  }
  if (n == 1) {
    if (m % 6 == 1 || m % 6 == 5) {
      cout << m - 1 << endl;
    } else if (m % 6 == 2 || m % 6 == 4) {
      cout << m - 2 << endl;
    } else if (m % 6 == 3) {
      cout << m - 3 << endl;
    } else {
      cout << m << endl;
    }
    return 0;
  }
  if (n % 2 == 1 && m % 2 == 0) {
    swap(n, m);
  }
  if (n % 2 == 0) {
    if (m == 3) {
      if (n >= 4)
        cout << m * n << endl;
      else
        cout << 4 << endl;
      return 0;
    }
    if (n == 2) {
      if (m == 7)
        cout << 12 << endl;
      else if (m == 3)
        cout << 4 << endl;
      else
        cout << m * n << endl;
      return 0;
    }
    if (n >= 4) {
      cout << m * n << endl;
      return 0;
    }
  }
  if (n > m) swap(n, m);
  cout << m * n - 1 << endl;
  return 0;
}
