#include <bits/stdc++.h>
using namespace std;
int fx[] = {1, -1, 0, 0};
int fy[] = {0, 0, 1, -1};
int main() {
  long long n, m;
  cin >> n >> m;
  if (n > m) swap(n, m);
  if (n == 1) {
    long long p = m % 6;
    long long aa = 0;
    if (p == 4)
      aa = 2;
    else if (p == 5)
      aa = 4;
    cout << (m / 6) * 6 + aa;
  } else if (n > 2 or m > 2) {
    if (n == 2 and (m == 3 or m == 7)) {
      cout << n * m - 2;
    } else if (n == 2)
      cout << n * m;
    else if ((n * m) % 2)
      cout << n * m - 1;
    else
      cout << n * m;
  } else
    cout << 0;
  return 0;
}
