#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long longinf = 1LL << 60;
const long long mod = 1e9 + 7;
int main() {
  long long x, y;
  cin >> x >> y;
  if (x > y) swap(x, y);
  if (x == 1) {
    if (y % 6 == 4)
      cout << y - 2 << endl;
    else if (y % 6 == 5)
      cout << y - 1 << endl;
    else
      cout << y - (y % 6) << endl;
    return 0;
  }
  if (x == 2) {
    if (y == 2)
      cout << 0 << endl;
    else if (y == 3)
      cout << 4 << endl;
    else if (y == 7)
      cout << 12 << endl;
    else
      cout << 2 * y << endl;
    return 0;
  }
  cout << x * y - (x * y) % 2 << endl;
  return 0;
}
