#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
  long long n, m;
  cin >> n >> m;
  long long S = n * m;
  if (n > m) swap(n, m);
  if (n == 1) {
    long long ans = (m / 6) * 6;
    m %= 6;
    if (m >= 4) ans += 2;
    if (m >= 5) ans += 2;
    cout << ans << endl;
  } else if (n == 2) {
    if (m == 2)
      cout << S - 4 << endl;
    else if (m == 3)
      cout << S - 2 << endl;
    else if (m == 7)
      cout << S - 2 << endl;
    else
      cout << S << endl;
  } else
    cout << S - (S & 1) << endl;
  return 0;
}
