#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  long long int x, y;
  cin >> x >> y;
  if ((x <= 3 && y <= 3 && x * y <= 3) || (x == 2 && y == 2)) {
    cout << "0\n";
    return 0;
  }
  if ((x >= 6 && x % 6 == 0) || (y >= 6 && y % 6 == 0)) {
    cout << x * y << "\n";
    return 0;
  }
  if (x == 1) {
    if (y == 4)
      cout << "2\n";
    else if (y == 5)
      cout << "4\n";
    else if (y % 6 <= 3)
      cout << y - y % 6 << "\n";
    else
      cout << y - (6 - y % 6) << "\n";
    return 0;
  }
  if (y == 1) {
    if (x == 4)
      cout << "2\n";
    else if (x == 5)
      cout << "4\n";
    else if (x % 6 <= 3)
      cout << x - x % 6 << "\n";
    else
      cout << x - (6 - x % 6) << "\n";
    return 0;
  }
  if (x < 6 && y < 6) {
    if (x * y == 6) {
      cout << "4\n";
      return 0;
    }
    cout << (x * y) - ((x * y) % 2) << "\n";
    return 0;
  }
  if (x % 2 == 0 && y % 2 == 0) {
    cout << x * y << "\n";
    return 0;
  }
  if (x % 2 == 1 && y % 2 == 1) {
    cout << (x * y) - 1 << "\n";
    return 0;
  }
  if ((x == 2 && y % 5 == 2 && y % 4 != 1) ||
      (y == 2 && x % 5 == 2 && x % 4 != 1)) {
    cout << x * y - 2 << "\n";
    return 0;
  }
  cout << x * y << "\n";
  return 0;
}
