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