#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long x, y, ans;
  while (cin >> x >> y) {
    if (x < y) swap(x, y);
    if (x <= 2 && y <= 2)
      ans = 0;
    else if (y == 1) {
      int a[6] = {3, 2, 1, 0, 1, 2};
      ans = x * y - a[(x - 3) % 6];
    } else if (y == 2) {
      if (x == 3)
        ans = 4;
      else if (x == 7)
        ans = 12;
      else
        ans = x * y;
    } else if (y >= 3)
      ans = (x * y % 2 == 1 ? x * y - 1 : x * y);
    cout << ans << endl;
  }
  return 0;
}
