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